def generate_neighbourhoods(self): coords = self.root.subtree_coords kd_tree = KDTree(coords) self.root.set_neighbours(kd_tree)