iterator pattern print(node dataif node right is not nonetree_traverse(node rightif __name__ ="__main__"root node(" am the root"root left node("first left child"root right node("first right child"root left right node("right child of first left child of root"tree_traverse(rootcontrast this to when you want to traverse simple listlst [ for in range(len(lst))print(lst[ ] know used the for loop in way that is not considered pythonicbut if you come from / +or java backgroundthis will look familiar do this because want to illustrate how you could traverse list and binary tree and how they are distinctly different processes that produce similar result alexander stepanovadvocate of generic programming and as the primary designer and implementer of the +standard template libraryspent lot of time thinking about the techniques of generic programmingwhere the code is written in terms of algorithms that operate on data types to be defined at some future time he married ideas from pure mathematics and algebra with computer science and concluded that most algorithms can be defined in relation to an algebraic data type called containers by decoupling the algorithm from the specific type and implementation of containeryou become free to describe the algorithm without paying any attention to the actual implementation details of the specific type of container the result of this decoupling is more generalmore reusable code we want to be able to traverse collection without worrying about whether we are dealing with list or binary tree or some other collection to do thiswe want to create an interface that collection data type can inheritwhich would allow it to generalize the action of traversing the contents of the collection we do this by using the following components