docs: private static SubstUnitInfo genFinalSubstUnitInfoMapsHelper(
        RepresentativeNodes representativeNodes) {
  
      // ------ Step 1: Build final map of var name to representative node. ------
      //
      // The final map substUnitVarNameToRepNodeMap must be a one-to-one mapping. If a base name only
      // maps to one representative node, then we simply put that same mapping into the final map. But
      // if a base name maps to multiple nodes, we must append number suffixes ("_1", "_2", etc) to
      // make the names unique.
      //
      // Note: We must be careful that, while appending number suffixes, we don't generate a new name
      // that is the same as an existing base name.
  
      Map<String, MsgSubstUnitNode> substUnitVarNameToRepNodeMap = new LinkedHashMap<>();
  
      for (String baseName : representativeNodes.baseNameToRepNodesMap().keys()) {
        List<MsgSubstUnitNode> nodesWithSameBaseName =
            representativeNodes.baseNameToRepNodesMap().get(baseName);
        if (nodesWithSameBaseName.size() == 1) {
          substUnitVarNameToRepNodeMap.put(baseName, nodesWithSameBaseName.get(0));
        } else {
          // Case 2: Multiple nodes generate this base name. Need number suffixes.
          int nextSuffix = 1;
          for (MsgSubstUnitNode repNode : nodesWithSameBaseName) {
            String newName;
            do {
              newName = baseName + "_" + nextSuffix;
              ++nextSuffix;
            } while (representativeNodes.baseNameToRepNodesMap().containsKey(newName));
            substUnitVarNameToRepNodeMap.put(newName, repNode);
          }
        }
      }
  
      // ------ Step 2: Create map of every node to its var name. ------
  
      Map<MsgSubstUnitNode, PlaceholderInfo> substUnitNodeToVarNameMap = new LinkedHashMap<>();
  
      // Reverse the map of names to representative nodes.
      for (Map.Entry<String, MsgSubstUnitNode> entry : substUnitVarNameToRepNodeMap.entrySet()) {
        substUnitNodeToVarNameMap.put(
            entry.getValue(),
            PlaceholderInfo.create(
                entry.getKey(), representativeNodes.repNodeToPhExample().get(entry.getValue())));
      }
  
      // Add mappings for the non-representative nodes.
      for (Map.Entry<MsgSubstUnitNode, MsgSubstUnitNode> entry :
          representativeNodes.nonRepNodeToRepNodeMap().entrySet()) {
        MsgSubstUnitNode nonRepNode = entry.getKey();
        MsgSubstUnitNode repNode = entry.getValue();
        substUnitNodeToVarNameMap.put(nonRepNode, substUnitNodeToVarNameMap.get(repNode));
      }
  
      return new SubstUnitInfo(
          ImmutableMap.copyOf(substUnitVarNameToRepNodeMap),
          ImmutableMap.copyOf(substUnitNodeToVarNameMap));
    }