public static List<Integer> postorderTraversalnonrecursive(TreeNode root) {
        ArrayList<Integer> arrlst = new ArrayList<Integer>();
        if (root == null) {
            return arrlst;
        }
        Stack<TreeNode> stk = new Stack<TreeNode>();
        while (true) {
            while (root != null) {
                arrlst.add(root.val);
                stk.push(root);
                root = root.left;
            }
            if (stk.isEmpty()) break;
            root = stk.pop();
            root = root.right;
        }
        return arrlst;
    }