1def is_symmetric(root):
2 if not root:
3 return True
4
5 def is_mirror(t1, t2):
6 if not t1 and not t2:
7 return True
8 if not t1 or not t2:
9 return False
10 return (t1.val == t2.val and
11 is_mirror(t1.left, t2.right) and
12 is_mirror(t1.right, t2.left))
13
14 return is_mirror(root.left, root.right)