# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def postorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
res = []
def tail(root):
if not root:
return None
tail(root.left) # 左右后
tail(root.right)
res.append(root.val)
tail(root)
return res