This function assumes the 2d distance is meant

def closest(self, ps: Union["Units", List["Point2"], Set["Point2"]]) -> Union["Unit", "Point2"]:
        """ This function assumes the 2d distance is meant """
        assert ps
        if len(ps) == 1:
            return ps[0]
        closest_distance_squared = math.inf
        for p2 in ps:
            p2pos = p2
            if not isinstance(p2pos, Point2):
                p2pos = p2.position
            distance = (self[0] - p2pos[0]) ** 2 + (self[1] - p2pos[1]) ** 2
            if distance < closest_distance_squared:
                closest_distance_squared = distance
                closest_element = p2
        return closest_element