code: private void addHeads(List<AttachedGroup> attachedSubstituents) {
          Iterator<AttachedGroup> substituentsIterator = attachedSubstituents.iterator();
          while (substituentsIterator.hasNext()) {
              AttachedGroup attachedSubstituent = substituentsIterator.next();
  
              Iterator<Token> locationsIterator = attachedSubstituent.getLocations().iterator();
              while (locationsIterator.hasNext()) {
                  Token locationToken = locationsIterator.next();
  
                  int joinLocation = Integer.parseInt(locationToken.image) - 1;
                  IAtom connectingAtom;
  
                  //If join location wasn't specified we must be dealing with the "hack" which makes
                  //mainchains a substituent if a real substituent has already been parsed and interpreted as a main chain
                  if (joinLocation < 0) {
                      connectingAtom = endOfChain;
                  } else {
                      connectingAtom = currentMolecule.getAtom(joinLocation);
                  }
  
                  IAtomContainer subChain = buildChain(attachedSubstituent.getLength(), false);
  
                  IBond linkingBond = currentMolecule.getBuilder().newInstance(IBond.class, subChain.getAtom(0),
                          connectingAtom);
                  currentMolecule.addBond(linkingBond);
                  currentMolecule.add(subChain);
              }
          }
      }
docs: Adds other chains to the main chain connected at the specified atom.
  
  @param attachedSubstituents A vector of AttachedGroup's representing substituents.