code: def _apply_filters_to_first_location_occurrence(match_traversal, location_to_filters,
                                                  already_filtered_locations):
      
      new_match_traversal = []
      newly_filtered_locations = set()
      for match_step in match_traversal:
          # Apply all filters for a location to the first occurence of that location
          current_location = match_step.as_block.location
  
          if current_location in newly_filtered_locations:
              raise AssertionError(u'The same location {} was encountered twice in a single '
                                   u'match traversal: {}. This should never happen.'
                                   .format(current_location, match_traversal))
  
          if all((current_location in location_to_filters,
                  current_location not in already_filtered_locations)):
              where_block = Filter(
                  _filter_list_to_conjunction_expression(
                      location_to_filters[current_location]
                  )
              )
              # No further filters needed for this location. If the same location is found in
              # another call to this function, no filters will be added.
              newly_filtered_locations.add(current_location)
          else:
              where_block = None
  
          new_match_step = MatchStep(
              root_block=match_step.root_block,
              coerce_type_block=match_step.coerce_type_block,
              where_block=where_block,
              as_block=match_step.as_block
          )
          new_match_traversal.append(new_match_step)
  
      return new_match_traversal, newly_filtered_locations
docs: Apply all filters for a specific location into its first occurrence in a given traversal.
  
      For each location in the given match traversal,
      construct a conjunction of all filters applied to that location,
      and apply the resulting Filter to the first instance of the location.
  
      Args:
          match_traversal: list of MatchStep objects to be lowered
          location_to_filters: dict mapping each location in the MatchQuery which contains
                               the given match traversal to a list of filters applied at that location
          already_filtered_locations: set of locations that have already had their filters applied
  
      Returns:
          new list of MatchStep objects with all filters for any given location composed into
          a single filter which is applied to the first instance of that location