public ArrayList<Integer> postorderTraversal(TreeNode root) {
        ArrayList<Integer> result = new ArrayList<Integer>();
        if (root == null) {
            return result;
        }
        Stack<TraverseWrapper> stack = new Stack<TraverseWrapper>();
        stack.push(new TraverseWrapper(root));
        while (!stack.isEmpty()) {
            TraverseWrapper crt = stack.peek();
            if (crt.status == 0) {
                if (crt.node.left != null) {
                    stack.push(new TraverseWrapper(crt.node.left));
                }
                crt.status = 1;
            }
            else if (crt.status == 1) {
                if (crt.node.right != null) {
                    stack.push(new TraverseWrapper(crt.node.right));
                }
                crt.status = 2;
            }
            else if (crt.status == 2) {
                result.add(crt.node.val);
                stack.pop();
            }
        }
        return result;
    }