class Solution:
def isSymmetric(self, root: Optional[TreeNode]) -> bool:
def check(l, r):
if not l and not r:
return True
if not l or not r:
return False
return l.val == r.val and check(l.left, r.right) and check(l.right, r.left)
return check(root.left, root.right)