def merge_to_polygon(p1, p2):
    """
    Merges two polygon objects, two polygon_domain objects,
    or combinations thereof, and returns a polygon object
    consisting of the merger of the polygons of the two
    argument objects
    """
    if hasattr(p1, 'polygon'):
        # assume polygon_domain
        p1 = p1.polygon
    if hasattr(p2, 'polygon'):
        # assume polygon_domain
        p2 = p2.polygon
    return p1.union(p2)