public static <T> void inorder_traversal(BinaryTree<T> n) {
        while(n != null) {
            if(n.getLeft() != null) {
                // Find the predecessor of n.
                BinaryTree<T> pre = n.getLeft();
                while(pre.getRight() != null && pre.getRight() != n) {
                    pre = pre.getRight();
                }

                // Process the successor link.
                if(pre.getRight() != null) { // pre.getRight() == n
                    // Revert the successor link if predecessor's successor is n.
                    pre.setRight(null);
                    System.out.println(n.getData());
                    n = n.getRight();
                } else { // if predecessor's successor is not n.
                    pre.setRight(n);
                    n = n.getLeft();
                }
            } else {
                System.out.println(n.getData());
                n = n.getRight();
            }
        }
    }