private void updateLeaves(Task node)
    {
        if (node.getSubtasks().isEmpty())
        {
            leaves.add(node);
        } 
        else
        {
            for (Task nodes : node.getSubtasks())
            {
                updateLeaves(nodes);
            }
        }
    }