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

        int postIndex = postorder.length - 1;
        int inIndex = postIndex;
        Stack<TreeNode> treeNodeStack = new Stack<TreeNode>();
        TreeNode root = new TreeNode(postorder[postIndex--]);
        treeNodeStack.push(root);
        TreeNode nowNode = root;
        boolean rightDone = false;

        while (postIndex >= 0) {
            if (treeNodeStack.size() != 0 && treeNodeStack.peek().val == inorder[inIndex]) {
                inIndex--;
                nowNode = treeNodeStack.pop();
                rightDone = true;
            } else {
                if (!rightDone) {
                    nowNode.right = new TreeNode(postorder[postIndex--]);
                    nowNode = nowNode.right;
                    treeNodeStack.push(nowNode);
                } else {
                    nowNode.left = new TreeNode(postorder[postIndex--]);
                    nowNode = nowNode.left;
                    treeNodeStack.push(nowNode);
                    rightDone = false;
                }
            }
        }

        return root;
    }