implementing tree traversals in python when first defining the tree adt in section we stated that tree should include support for the following methodst positions)generate an iteration of all positions of tree iter( )generate an iteration of all elements stored within tree at that timewe did not make any assumption about the order in which these iterations report their results in this sectionwe demonstrate how any of the tree traversal algorithms we have introduced could be used to produce these iterations to beginwe note that it is easy to produce an iteration of all elements of treeif we rely on presumed iteration of all positions thereforesupport for the iter(tsyntax can be formally provided by concrete implementation of the special method iter within the abstract base class tree we rely on python' generator syntax as the mechanism for producing iterations (see section our implementation of tree iter is given in code fragment def iter (self)"""generate an iteration of the tree elements ""for in self positions)use same order as positions(yield elementbut yield each element code fragment iterating all elements of tree instancebased upon an iteration of the positions of the tree this code should be included in the body of the tree class to implement the positions methodwe have choice of tree traversal algorithms given that there are advantages to each of those traversal orderswe will provide independent implementations of each strategy that can be called directly by user of our class we can then trivially adapt one of those as default order for the positions method of the tree adt preorder traversal we begin by considering the preorder traversal algorithm we will support public method with calling signature preorderfor tree twhich generates preorder iteration of all positions within the tree howeverthe recursive algorithm for generating preorder traversalas originally described in code fragment must be parameterized by specific position within the tree that serves as the root of subtree to traverse standard solution for such circumstance is to define nonpublic utility method with the desired recursive parameterizationand then to have the public method preorder invoke the nonpublic method upon the root of the tree our implementation of such design is given in code fragment