code: private void preorderTreeDepth(INode root, HashMap<INode, Integer> order, HashMap<INode, Integer> depth) {
          order.clear();
          depth.clear();
  
          int num = 1;
  
          Deque<INode> stack = new ArrayDeque<INode>();
          stack.push(root);
          while (!stack.isEmpty()) {
              INode v = stack.pop();
  
              order.put(v, num++);
              if (!v.hasParent()) {
                  depth.put(v, 0);
              } else {
                  depth.put(v, depth.get(v.getParent()) + 1);
              }
  
              for (int i = v.getChildCount() - 1; i >= 0; i--) {
                  stack.push(v.getChildAt(i));
              }
          }
      }
docs: Implementing method "preorder_tree_depth" by Gabriel Valiente: See
  http://www.lsi.upc.es/~valiente/algorithm/combin.cpp
  
  @param root root
  @param order order
  @param depth depth