1class Solution {2public boolean isSymmetric(TreeNode root) {3return isSymmetric(root.left, root.right);4}56public boolean isSymmetric(TreeNode rootLeft, TreeNode rootRight) {7if (rootLeft == null && rootRight == null) {8return true;9}10if (rootLeft == null || rootRight == null) {11return false;12}13if (rootLeft.val != rootRight.val) {14return false;15} else16return isSymmetric(rootLeft.right, rootRight.left)17&& isSymmetric(rootLeft.left, rootRight.right);18}19}