code: def walk(self, leavesonly=True, maxdepth=None, _depth = 0):
          
          if self.children:
              if not maxdepth or (maxdepth and _depth < maxdepth):
                  for key, child in self.children.items():
                      if child.leaf():
                          yield child
                      else:
                          for results in child.walk(leavesonly, maxdepth, _depth + 1):
                              yield results
docs: Depth-first search, walking through trie, returning all encounterd nodes (by default only leaves)