public void walk(Node nd) throws SemanticException {
      if(!(nd instanceof Task)){
        throw new SemanticException("Task Graph Walker only walks for Task Graph");
      }

      if (getDispatchedList().contains(nd)) {
        return;
      }
      if (opStack.empty() || nd != opStack.peek()) {
        opStack.push(nd);
      }

      List<Task<?>> nextTaskList = null;
      Set<Task<?>> nextTaskSet = new HashSet<Task<?>>();
      List<Task<?>> taskListInConditionalTask = null;


      if(nd instanceof ConditionalTask ){
        //for conditional task, next task list should return the children tasks of each task, which
        //is contained in the conditional task.
        taskListInConditionalTask = ((ConditionalTask) nd).getListTasks();
        for(Task<?> tsk: taskListInConditionalTask){
          List<Task<?>> childTask = tsk.getChildTasks();
          if(childTask != null){
            nextTaskSet.addAll(tsk.getChildTasks());
          }
        }
        //convert the set into list
        if(nextTaskSet.size()>0){
          nextTaskList = new ArrayList<Task<?>>();
          for(Task<?> tsk:nextTaskSet ){
            nextTaskList.add(tsk);
          }
        }
      }else{
        //for other tasks, just return its children tasks
        nextTaskList = ((Task<?>)nd).getChildTasks();
      }

      if ((nextTaskList == null)
          || getDispatchedList().containsAll(nextTaskList)) {
        dispatch(nd, opStack,this.walkerCtx);
        opStack.pop();
        return;
      }
      // add children, self to the front of the queue in that order
      getToWalk().add(0, nd);
      getToWalk().removeAll(nextTaskList);
      getToWalk().addAll(0, nextTaskList);

  }
walk the current operator and its descendants.

@param nd
         current operator in the graph
@throws SemanticException
ql/src/java/org/apache/hadoop/hive/ql/lib/TaskGraphWalker.java