title: How to determine if a Binary Tree node is a Left or Right child?
body: <p>I have a simple Tree data structure, however, I would like to implement two methods named <code>isLeftChild</code> and <code>isRightChild</code>.</p>
  
  <p>The problem is I am having a very hard time understanding trees. The concept and general process has not fully been grasped.</p>
  
  <p>Here is my simple tree so far:</p>
  
  <pre><code>class Node(object):
      ''' A tree node. '''
      def __init__(self, data):
          self.left = None
          self.right = None
          self.data = data
  
      def isLeftChild(self):
          ''' Returns True if the node is a left child, else False. '''
          pass
  
      def isRightChild(self):
          ''' Returns True if the node is a right child, else False. '''
          pass
  
      def insert(self, data):
          ''' Populate the tree. '''
          if self.data:
              if data &lt; self.data:
                  if self.left is None:
                      self.left = Node(data)
                  else:
                      self.left.insert(data)
              elif data &gt; self.data:
                  if self.right is None:
                      self.right = Node(data)
                  else:
                      self.right.insert(data)
          else:
              self.data = data
  
      def printTree(self):
          ''' Display the tree. '''
          if self.left:
              self.left.printTree()
          print self.data
          if self.right:
              self.right.printTree()
  
  def main():
      root = Node(8)
      root.insert(2)
      root.printTree()
  
  main()
  </code></pre>
  
  <p><strong>How can I have a node determine if it is a left child or a right child</strong> <strong><em>(without reference to its <code>data</code>)</em></strong>?</p>
  
  <p>I am not sure what I need to add to my tree in order to determine this.</p>