Binary Tree Iterator
1. Binary Tree Iterator
// binary iterator
class BinaryIterator {
    Node curr;
    Stack<Node> stack;
    public BinaryIterator(Node root) {
        curr = root;
        stack = new Stack<Node>();
    }

    public boolean hasNext() {
        return (curr != null || stack.isEmpty() == false);
    }

    public Node next() {
        while(hasNext()) {
            if(curr != null) {
                stack.push(curr);
                curr = curr.left;
            } else {
                Node node = stack.pop();
                curr = node.right;
                return node;
            }
        }
        return null;
    }
}