@Override
    protected void walk(Node nd) throws SemanticException {

      List<Node> parents = ((Operator) nd).getParentOperators();
      if ((parents == null)
          || getDispatchedList().containsAll(parents)) {
        opStack.push(nd);

        // all parents are done or no need to walk the parents
        dispatch(nd, opStack);
        opStack.pop();
      } else {
        toWalk.removeAll(parents);
        toWalk.add(0, nd);
        toWalk.addAll(0, parents);
        return;
      }

      // move all the children to the end of queue
      List<? extends Node> children = nd.getChildren();
      if (children != null) {
        toWalk.removeAll(children);
        toWalk.addAll(children);
      }
    }
Walks the op tree in root first order.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagate.java