code: def iterate_with_selected_objects_in_order(analysis_objects: Mapping[Any, Any],
                                             analysis_iterables: Dict[str, Sequence[Any]],
                                             selection: Union[str, Sequence[str]]) -> Iterator[List[Tuple[Any, Any]]]:
      if isinstance(selection, str):
          selection = [selection]
      assert not isinstance(selection, str)
      analysis_iterables = copy.copy(analysis_iterables)
      selected_iterators = {}
      for s in selection:
          selected_iterators[s] = analysis_iterables.pop(s)
      logger.debug(f"Initial analysis_iterables: {analysis_iterables}")
      logger.debug(f"Initial selected_iterators: {selected_iterators}")
      selected_iterators = [[(k, v) for v in values] for k, values in selected_iterators.items()]
      analysis_iterables = [[(k, v) for v in values] for k, values in analysis_iterables.items()]
      logger.debug(f"Final analysis_iterables: {analysis_iterables}")
      logger.debug(f"Final selected_iterators: {selected_iterators}")
      for values in itertools.product(*analysis_iterables):
          selected_analysis_objects = []
          for selected_values in itertools.product(*selected_iterators):
              for key_index, obj in analysis_objects.items():
                  selected_via_analysis_iterables = all(
                      getattr(key_index, k) == v for k, v in values
                  )
                  selected_via_selected_iterators = all(
                      getattr(key_index, k) == v for k, v in selected_values
                  )
                  selected_obj = selected_via_analysis_iterables and selected_via_selected_iterators
                  if selected_obj:
                      selected_analysis_objects.append((key_index, obj))
          logger.debug(f"Yielding: {selected_analysis_objects}")
          yield selected_analysis_objects