code: private List<Integer> getAttachedInOrder(IRing macrocycle, IAtomContainer shared) {
          List<Integer> ringAttach = new ArrayList<>();
          Set<IAtom> visit = new HashSet<>();
          IAtom atom = shared.getAtom(0);
          while (atom != null) {
              visit.add(atom);
              ringAttach.add(macrocycle.indexOf(atom));
              List<IAtom> connected = shared.getConnectedAtomsList(atom);
              atom = null;
              for (IAtom neighbor : connected) {
                  if (!visit.contains(neighbor)) {
                      atom = neighbor;
                      break;
                  }
              }
          }
          return ringAttach;
      }
docs: Get the shared indices of a macrocycle and atoms shared with another ring.
  
  @param macrocycle macrocycle ring
  @param shared shared atoms
  @return the integers