Check if There are Any Active Tasks on Lead Before Creating New Tasks

Check if There are Any Active Tasks on Lead Before Creating New Tasks

Hi, 

I am working on creating a flow such that the trigger will be a task being completed. I want to create a new task very time a task is closed but only if the Lead on the task being closed has no more additional open tasks.

I am having a hard time running a check/search on the Lead associated with the tasks that was just closed to see if they have any open tasks. Is there a custom function I can write to check the number of open tasks on a lead?

Any help would be much appreciated