public static <T> List<T> inorderTraversal(BinaryTree<T> root) {
        if (root == null) {
            return null;
        }
        List<T> list = new ArrayList<T>();
        BinaryTree<T> prev = root.getParent();
        BinaryTree<T> current = root;
        BinaryTree<T> next = null;
        while (current != null) {
            if (prev == null || prev.getLeft() == current || prev.getRight() == current) {
                if (current.getLeft() != null) {
                    next = current.getLeft();
                } else {
                    list.add(current.getData());
                    next = current.getRight() == null ? current.getParent() : current.getRight();
                }
            } else if (current.getLeft() == prev) {
                list.add(current.getData());
                next = current.getRight() == null ? current.getParent() : current.getRight();
            } else {
                next = current.getParent();
            }
            prev = current;
            current = next;
        }
        return list;
    }