title: Same tree verification through recursive tree traversal
body: <p>I've prepared a recursive tree-traversal based solution to the <a href="https://leetcode.com/problems/same-tree/" rel="nofollow noreferrer">&quot;same tree&quot; problem</a>. However, I'm encountering an error on use cases involving None values. Why is my approach incorrect and how should I be altered to handle the use case?</p>
  <pre class="lang-py prettyprint-override"><code>class Solution(object):
      
      def traversal(self,root):
          visited = []
          
          if root:
              if root.left:
                  visited.extend(self.traversal(root.left))
  
              visited.append(root.val)
  
              if root.right:
                  visited.extend(self.traversal(root.right))   
              
          return visited             
      
      def isSameTree(self, p, q):
          &quot;&quot;&quot;
          :type p: TreeNode
          :type q: TreeNode
          :rtype: bool
          &quot;&quot;&quot;
      
          p_path = self.traversal(p)
          q_path = self.traversal(q)
          print(p_path, q_path)
          return p_path == q_path
  </code></pre>
  <p>Use case: input([1,1][1,null,1]), output(true), stdout([1,1], [1,1])</p>