public static void inOrderTraversal(BinaryTree<Integer> T) {
        // Empty tree.
        if (T == null) {
            return;
        }

        BinaryTree<Integer> prev = null, curr = T, next;
        while (curr != null) {
            if (prev == null || prev.getLeft() == curr || prev.getRight() == curr) {
                if (curr.getLeft() != null) {
                    next = curr.getLeft();
                } else {
                    System.out.println(curr.getData());
                    next = (curr.getRight() != null ? curr.getRight() : curr.getParent());
                }
            } else if (curr.getLeft() == prev) {
                System.out.println(curr.getData());
                next = (curr.getRight() != null ? curr.getRight() : curr.getParent());
            } else {
                // curr.getRight() == prev.
                next = curr.getParent();
            }

            prev = curr;
            curr = next;
        }
    }