This method recursively walks the tree, yielding the current node, followed by its subtrees.
# - - - T a x o n P h o t o S e t . w a l k def walk(self): '''Recursive tree walker, yielding nodes in pre-order. '''
The current node is generated first.
#-- 1 yield self
This method specifies that the children are generated in
taxonomic order. Since the keys in the
self._childMap dictionary are in phylogenetic
order, we extract the key set, sort it, and then
recursively generate the subtrees in order by that set.
#-- 2 # [ childKeys := a list containing the keys of # self._childMap in ascendind order ] childKeys = self._childMap.keys() childKeys.sort() #-- 3 # [ childKeys is a list of keys in self._childMap -> # generate the nodes from subtrees rooted in the nodes # that are values of self._childMap, in childKeys order ] for txKey in childKeys: childNode = self._childMap[txKey] for node in childNode.walk(): yield node