figure simple tree using nodes and references approach modify self left_child in the root to reference the new tree class binarytreedef __init__(selfroot)self key root self left_child none self right_child none notice that the constructor function expects to get some kind of object to store in the root just like you can store any object you like in listthe root object of tree can be reference to any object for our early exampleswe will store the name of the node as the root value using nodes and references to represent the tree in figure we would create six instances of the binarytree class next let' look at the functions we need to build the tree beyond the root node to add left child to the treewe will create new binary tree object and set the left attribute of the root to refer to this new object the code for insert_left is shown below def insert_left(self,new_node)if self left_child =noneself left_child binarytree(new_nodeelset binarytree(new_nodet left_child self left_child self left_child we must consider two cases for insertion the first case is characterized by node with no existing left child when there is no left childsimply add node to the tree the second case is characterized by node with an existing left child in the second casewe insert node and push the existing child down one level in the tree the second case is handled by the else statement on line of insert_left the code for insert_right must consider symmetric set of cases there will either be no right childor we must insert the node between the root and an existing right child the insertion code is shown below implementation