思路:

1、两棵树p1、p2, p1与p2,p1的左与p2的右,p1的右与p2的左相同,则对称

2、递归判断全部节点

class Solution:
    def isSymmetrical(self , pRoot: TreeNode) -> bool:
        # write code here
        if not pRoot:
            return True
        
        return self.check(pRoot, pRoot)
        
    def check(self, p1, p2):
        if not p1 and not p2:
            return True
        
        if not p1 or not p2:
            return False
        
        return p1.val == p2.val and self.check(p1.left, p2.right) and self.check(p1.right, p2.left)