title: Tree traversal in python how to determine parent node after printing child node
body: <p>In the following code the tree has 5 elements  ,where A has (B,C) and B has (D,E), my question is after printing the last element ,and that node is D how does the node switches to 'B' in the following code,can some one explain this code please</p>
  
  <pre><code>class trees(object):
      def __init__(self,name,left=None,right=None):
              self.name = name
              self.left = None
              self.right = None
  
  def inorderTraversal(root):
       res = []
       if root:
              res = inorderTraversal(root.left) 
              print root.name
              res = res + inorderTraversal(root.right)
  
  t1=trees('A')
  t2=trees('B')
  t3=trees('C')
  t4=trees('D')
  t5=trees('E')
  
  t1.left = t2
  t1.right = t3
  t2.left= t4
  t2.right = t5
  
  inorderTraversal(t1) 
  #prints D,B,E,A,C
  </code></pre>