class Solution:
def isSymmetric(self, root: Optional[TreeNode]) -> bool:
if root is None:
return True
return self.isSym(root.left, root.right)
def isSym(self, l, r):
if l is None and r is not None:
return False
elif l is not None and r is None:
return False
elif l is None and r is None:
return True
if l.val != r.val:
return False
# else:
# return True
return self.isSym(l.left, r.right) and self.isSym(l.right, r.left)