Adding getNeighborsND function