class Solution:
def postorderTraversal(self, root: TreeNode) -> List[int]:
if root is None:
return []
res, stack = [], [root]
while stack:
node = stack.pop(-1)
res.append(node.val)
if node.left is not None:
stack.append(node.left)
if node.right is not None:
stack.append(node.right)
return res[::-1]