docs: def collect(nested_nodes, transform=None):
      '''
      Return list containing the result of the `transform` function applied to
      each item in the supplied list of nested nodes.
  
      A custom transform function may be applied to each entry during the
      flattening by specifying a function through the `transform` keyword
      argument.  The `transform` function will be passed the following arguments:
  
       - `node`: The node/key of the entry.
       - `parents`: The node/key of the parents as a `list`.
       - `nodes`: The children of the entry.
  
      By default, the `transform` function simply returns the node/key, resulting
      in a flattened version of the original nested nodes structure.
      '''
      items = []
  
      if transform is None:
          transform = lambda node, parents, nodes, *args: node
  
      def __collect__(node, parents, nodes, first, last, depth):
          items.append(transform(node, parents, nodes, first, last, depth))
  
      apply_depth_first(nested_nodes, __collect__)
      return items