public int next(){
  TreeNode n=stack.pop();
  pushAll(n.right);
  return n.val;
}

public int next ( ) { TreeNode n = stack . pop ( ) ; pushAll ( n . right ) ; return n . val ; }
to get the next smallest value . we pop the leftmost leaf from the stack . then we add all its right child ' s left children to stack . imagine all left children of a node is popped out . the next will be itself . and the next will be its right child ' s leftmost child .
