finished getNeighborsND (not tested yet)