public List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> result = new ArrayList<Integer>();
        if(root == null) return result;

        Stack<TreeNode> tmpStack = new Stack<TreeNode>();
        Stack<TreeNode> outStack = new Stack<TreeNode>();
        tmpStack.push(root);

        while(!tmpStack.isEmpty()){
            TreeNode node = tmpStack.pop();
            outStack.push(node);
            if(node.left != null) tmpStack.add(node.left);
            if(node.right != null) tmpStack.add(node.right);
        }

        while(!outStack.isEmpty()){
            result.add(outStack.pop().val);
        }
        return result;
    }