code: def iterate_nested(
      nd: NestedDict, previous_keys: Optional[KeyList] = None
  ) -> Iterator[Tuple[KeyList, LeafType]]:
      """Creates an iterator over every leaf value in depth first order.
  
      Iterates over a nested dictionary in depth first order. The order in which
      the peer keys are traversed is not guaranteed (same as for the keys of a
      dictionary).
  
      ```Example
      nested_dict = {'a': 1, 'b': [2, 3, 4], 'c': {'d': 8}}
      for k, v in iterate_nested(nested_dict):
        print('_'.join(k), v)
      # Prints out:
      # a: 1
      # b: [2, 3, 4]
      # c_d: 8
      ```
  
      Args:
        nd: The dictionary to be traversed.
        previous_keys: If supplied, the computed key list will be a join of the
          previous_keys and the current keys.
  
      Yields:
        A tuple of the key path and the value for each leaf node.
      """
      if previous_keys is None:
          previous_keys = []
      for k, v in nd.items():
          keys = previous_keys + [k]
          if not _is_nested(v):
              yield keys, v
          else:  # It is nested.
              as_dict = (
                  dataclasses.asdict(v)
                  if dataclasses.is_dataclass(v)
                  else v
              )
              for val in iterate_nested(as_dict, keys):
                  yield val
  
imports: import dataclasses
  from typing import Any, Dict, Tuple, Union, Iterator, List, Optional
label_desc: Use image node_id 1 for calling a global function with example usage: iterate_nested(nd, previous_keys) without return types