iterator pattern if we were to implement the binary tree we saw at the beginning of this as python iterableit would be implemented as followsbin_tree_iterator py class node(object)def __init__(selfdata)self data data self left none self right none class mytree(object)def __init__(selfroot)self root root def add_node(selfnode)current self root while trueif node data <current dataif current left is nonecurrent left node return elsecurrent current left elseif current right is nonecurrent right node return elsecurrent current right def __iter__(self)if self root is noneself stack [elseself stack [self rootcurrent self root