Kd tree is looking better, although still a bit wonky. possibly the best that can be hoped for from a naive spatial median approach