Fix NullPointerException occured while handling getNextNeighbors