private void getLeafTasks(Task<?> task,
      Set<Task<?>> leaves) {
    if (task.getDependentTasks() == null) {
      if (!leaves.contains(task)) {
        leaves.add(task);
      }
    } else {
      getLeafTasks(task.getDependentTasks(), leaves);
    }
  }
Find all leaf tasks of the list of root tasks.
ql/src/java/org/apache/hadoop/hive/ql/parse/TaskCompiler.java