public TreeNode fromPreInorder2(int[] preorder, int[] inorder) {
        if(preorder.length == 0) return null;

        Stack<TreeNode> treeNodeStack = new Stack<TreeNode>();

        TreeTest treeTest = new TreeTest();
        TreeNode root = null;
        TreeNode top = null;
        int i = 0;
        int j = 0;
        int f = 0;

        root = new TreeNode(preorder[i++]);
        top = root;
        treeNodeStack.push(root);

        while (i < preorder.length) {
            if (treeNodeStack.size() != 0 && treeNodeStack.peek().val == inorder[j]) {
                top = treeNodeStack.pop();
                f = 1;
                j++;
                System.out.print("===================\n");
                treeTest.printTree(root);
                System.out.print("i=="+i+"  j=="+j+"  f=="+f+"\n");
            } else {
                if (f == 0) {
                    top.left = new TreeNode(preorder[i++]);
                    top = top.left;
                    treeNodeStack.push(top);
                } else {
                    f = 0;
                    top.right = new TreeNode(preorder[i++]);
                    top = top.right;
                    treeNodeStack.push(top);
                }
                System.out.print("--------------------\n");
                treeTest.printTree(root);
                System.out.print("i=="+i+"  j=="+j+"  f=="+f+"\n");
            }
        }
        System.out.print("================\n");

        return root;
    }