Renamed variables
Optimized getNeighborsND
Simplified code
Update test