bool TreeTraversal(TreeNode *p, TreeNode *q){ if(!p&&!q) return true; bool result=false; if (p&&q) { if (p->val!=q->val) result = false; else result = isSameTree(p->left,q->left)&&isSameTree(p->right,q->right); }else{ result=false; } return result; }