Quick nearest neighbour hierarchy I wrote on the train. Needs improving.