code: public IAtomContainer getPath(IAtomContainer spt, IAtom atom1, IAtom atom2) throws NoSuchAtomException {
          IAtomContainer path = spt.getBuilder().newInstance(IAtomContainer.class);
          PathTools.resetFlags(spt);
          path.addAtom(atom1);
          PathTools.depthFirstTargetSearch(spt, atom1, atom2, path);
          if (path.getAtomCount() == 1) path.removeAtomOnly(atom1); // no path found: remove initial atom
          return path;
      }
docs: Find a path connected <i>a1</i> and <i>a2</i> in the tree. If there was
  an edge between <i>a1</i> and <i>a2</i> this path is a cycle.
  
  @param spt spanning tree
  @param atom1  start of path (source)
  @param atom2  end of path (target)
  @return a path through the spanning tree from the source to the target
  @throws NoSuchAtomException thrown if the atom is not in the spanning
  tree