code: def traverse_preorder(self, leaves=True, internal=True):
          '''Perform a preorder traversal starting at this ``Node`` object
  
          Args:
              ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False``
  
              ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False``
          '''
          s = deque(); s.append(self)
          while len(s) != 0:
              n = s.pop()
              if (leaves and n.is_leaf()) or (internal and not n.is_leaf()):
                  yield n
              s.extend(n.childrenf traverse_preorder(self, leaves=True, internal=True):
          '''Perform a preorder traversal starting at this ``Node`` object
  
          Args:
              ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False``
  
              ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False``
          '''
          s = deque(); s.append(self)
          while len(s) != 0:
              n = s.pop()
              if (leaves and n.is_leaf()) or (internal and not n.is_leaf()):
                  yield n
              s.extend(n.children)
docs: Perform a preorder traversal starting at this ``Node`` object
  
          Args:
              ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False``
  
              ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False``