Using kd tree instead of grid neighbour query