code: private List<IAtomContainer> mergeAtomicIons(final List<IAtomContainer> frags) {
          final List<IAtomContainer> res = new ArrayList<>(frags.size());
          for (IAtomContainer frag : frags) {
  
              IChemObjectBuilder bldr = frag.getBuilder();
  
              if (frag.getBondCount() > 0 || res.isEmpty()) {
                  res.add(bldr.newInstance(IAtomContainer.class, frag));
              } else {
                  // try to find matching atomic ion
                  int i = 0;
                  while (i < res.size()) {
                      IAtom iAtm = frag.getAtom(0);
                      if (res.get(i).getBondCount() == 0) {
                          IAtom jAtm = res.get(i).getAtom(0);
                          if (nullAsZero(iAtm.getFormalCharge()) == nullAsZero(jAtm.getFormalCharge()) &&
                              nullAsZero(iAtm.getAtomicNumber()) == nullAsZero(jAtm.getAtomicNumber()) &&
                              nullAsZero(iAtm.getImplicitHydrogenCount()) == nullAsZero(jAtm.getImplicitHydrogenCount())) {
                              break;
                          }
                      }
                      i++;
                  }
  
                  if (i < res.size()) {
                      res.get(i).add(frag);
                  } else {
                      res.add(bldr.newInstance(IAtomContainer.class, frag));
                  }
              }
          }
          return res;
      }
docs: Merge fragments with duplicate atomic ions (e.g. [Na+].[Na+].[Na+]) into
  single fragments.
  
  @param frags input fragments (all connected)
  @return the merge ions