code: public static IAtom[] findClosestByBond(IAtomContainer atomContainer, IAtom atom, int max) {
          IAtomContainer mol = atomContainer.getBuilder().newInstance(IAtomContainer.class);
          List<IAtom> v = new ArrayList<IAtom>();
          v.add(atom);
          breadthFirstSearch(atomContainer, v, mol, max);
          IAtom[] returnValue = new IAtom[mol.getAtomCount() - 1];
          int k = 0;
          for (int i = 0; i < mol.getAtomCount(); i++) {
              if (!mol.getAtom(i).equals(atom)) {
                  returnValue[k] = mol.getAtom(i);
                  k++;
              }
          }
          return (returnValue);
      }
docs: Returns the atoms which are closest to an atom in an AtomContainer by bonds.
  If number of atoms in or below sphere x&lt;max and number of atoms in or below sphere x+1&gt;max then
  atoms in or below sphere x+1 are returned.
  
  @param atomContainer The AtomContainer to examine
  @param atom          the atom to start from
  @param max           the number of neighbours to return
  @return the average bond length