def breadthfirst(self)"""generate breadth-first iteration of the positions of the tree ""if not self is empty)fringe linkedqueueknown positions not yet yielded fringe enqueue(self root)starting with the root while not fringe is empty) fringe dequeueremove from front of the queue yield report this position for in self children( )fringe enqueue(cadd children to back of queue code fragment an implementation of breadth-first traversal of tree this code should be included in the body of the tree class def inorder(self)"""generate an inorder iteration of positions in the tree ""if not self is empty)for in self subtree inorder(self root))yield def subtree inorder(selfp)"""generate an inorder iteration of positions in subtree rooted at ""if self left(pis not noneif left child existstraverse its subtree for other in self subtree inorder(self left( ))yield other yield visit between its subtrees if self right(pis not noneif right child existstraverse its subtree for other in self subtree inorder(self right( ))yield other code fragment support for performing an inorder traversal of binary tree this code should be included in the binarytree class (given in code fragment for many applications of binary treesan inorder traversal provides natural iteration we could make it the default for the binarytree class by overriding the positions method that was inherited from the tree class (see code fragment override inherited version to make inorder the default def positions(self)"""generate an iteration of the tree positions ""return self inordermake inorder the default code fragment defining the binarytree position method so that positions are reported using inorder traversal