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