def _ConvertAggregatedResultsToStringMap(aggregated_results):
  """Converts aggregated results to a format usable by _RecursiveHtmlToFile.

  Specifically, updates the string representation of the typ tags and replaces
  the lowest level dict with the build URL list.

  Args:
    aggregated_results: A map containing the aggregated test results.

  Returns:
    A map in the format:
    {
      'suite': {
        'test': {
          'space separated typ tags': ['build', 'url', 'list']
        }
      }
    }
  """
  string_map = {}
  for suite, test_map in aggregated_results.items():
    for test, tag_map in test_map.items():
      for typ_tags, build_url_list in tag_map.items():
        str_typ_tags = ' '.join(typ_tags)
        string_map.setdefault(suite,
                              {}).setdefault(test,
                                             {})[str_typ_tags] = build_url_list
  return string_map