code: public IAtom getPlacedHeavyAtomInAtomContainer(IAtom atomA, IAtom atomB, IAtomContainer ac) {
          List atoms = ac.getConnectedAtomsList(atomA);
          IAtom atom = null;
          for (int i = 0; i < atoms.size(); i++) {
              IAtom curAtom = (IAtom) atoms.get(i);
              if (curAtom.getFlag(CDKConstants.ISPLACED) && !curAtom.getSymbol().equals("H") && !Objects.equals(curAtom, atomB)) {
                  return curAtom;
              }
          }
          return atom;
      }
docs: Returns a placed neighbouring atom of a central atom atomA, which is not
  atomB.
  
  @param  atomA  central atom (Atom)
  @param  atomB  atom connected to atomA (Atom)
  @param  ac     molecule
  @return        returns a connected atom (Atom)