title: Construct Binary Tree
body: <p>How to construct the binary tree considering the following pattern – left &amp; right child, as well as a parent?</p>
  <pre><code>class BinaryTree:
      def __init__(self, value, left=None, right=None, parent=None):
          self.value = value
          self.left = left
          self.right = right
          self.parent = parent
  </code></pre>
  <p>I used the simplest pattern before.</p>
  <pre><code>tree = BinaryTree(1)
  tree.left = BinaryTree(2)
  tree.right = BinaryTree(3)
  tree.left.left = BinaryTree(4)
  tree.left.left.left = BinaryTree(6)
  tree.left.right = BinaryTree(5)
  
  #              1
  #            /   \
  #           2     3
  #         /  \
  #        4    5
  #       /
  #      6
  </code></pre>