Implement neighborsWithHistory and add test.