@SuppressWarnings({"unchecked", "rawtypes"})
  public static List<Task<?>>
      findLeafs(List<Task<?>> rootTasks) {
    final List<Task<?>> leafTasks = new ArrayList<Task<?>>();

    NodeUtils.iterateTask(rootTasks, Task.class, new NodeUtils.Function<Task>() {
      @Override
      public void apply(Task task) {
        List dependents = task.getDependentTasks();
        if (dependents == null || dependents.isEmpty()) {
          leafTasks.add(task);
        }
      }
    });
    return leafTasks;
  }
Add a dependent task on the current task. Return if the dependency already existed or is this a
new one

@return true if the task got added false if it already existed
ql/src/java/org/apache/hadoop/hive/ql/exec/Task.java