code: def UnrecognizedFieldIter(message, _edges=()):  # pylint: disable=invalid-name
      
      if not isinstance(message, messages.Message):
          # This is a primitive leaf, no errors found down this path.
          return
  
      field_names = message.all_unrecognized_fields()
      if field_names:
          # This message is malformed. Stop recursing and report it.
          yield _edges, field_names
          return
  
      # Recurse through all fields in the current message.
      for field in message.all_fields():
          value = message.get_assigned_value(field.name)
          if field.repeated:
              for i, item in enumerate(value):
                  repeated_edge = ProtoEdge(EdgeType.REPEATED, field.name, i)
                  iter_ = UnrecognizedFieldIter(item, _edges + (repeated_edge,))
                  for (e, y) in iter_:
                      yield e, y
          elif _IsMap(message, field):
              for key, item in _MapItems(message, field):
                  map_edge = ProtoEdge(EdgeType.MAP, field.name, key)
                  iter_ = UnrecognizedFieldIter(item, _edges + (map_edge,))
                  for (e, y) in iter_:
                      yield e, y
          else:
              scalar_edge = ProtoEdge(EdgeType.SCALAR, field.name, None)
              iter_ = UnrecognizedFieldIter(value, _edges + (scalar_edge,))
              for (e, y) in iter_:
                  yield e, y
docs: Yields the locations of unrecognized fields within "message".
  
      If a sub-message is found to have unrecognized fields, that sub-message
      will not be searched any further. We prune the search of the sub-message
      because we assume it is malformed and further checks will not yield
      productive errors.
  
      Args:
        message: The Message instance to search.
        _edges: Internal arg for passing state.
  
      Yields:
        (edges_to_message, field_names):
          edges_to_message: List[ProtoEdge], The edges (relative to "message")
              describing the path to the sub-message where the unrecognized
              fields were found.
          field_names: List[Str], The names of the field(s) that were
              unrecognized in the sub-message.