code: def _build_codes_reverse(
          codes: Dict[str, Dict[str, str]]) -> Dict[str, Dict[str, str]]:
      
      built = {}  # type: Dict[str, Dict[str, str]]
      for codetype, codemap in codes.items():
          for name, escapecode in codemap.items():
              # Skip shorcut aliases to avoid overwriting long names.
              if len(name) < 2:
                  continue
              if built.get(codetype, None) is None:
                  built[codetype] = {}
              built[codetype][escapecode] = name
      return built
docs: Build a reverse escape-code to name map, based on an existing
          name to escape-code map.