'Helper function to obtain a Path from one bbox to another.
Parameters
bbox1, bbox2 : `matplotlib.transforms.Bbox`
Bounding boxes to connect.
loc1 : {1, 2, 3, 4}
Corner of *bbox1* to use. Valid values are::
\'upper right\'  : 1,
\'upper left\'   : 2,
\'lower left\'   : 3,
\'lower right\'  : 4
loc2 : {1, 2, 3, 4}, optional
Corner of *bbox2* to use. If None, defaults to *loc1*.
Valid values are::
\'upper right\'  : 1,
\'upper left\'   : 2,
\'lower left\'   : 3,
\'lower right\'  : 4
Returns
path : `matplotlib.path.Path`
A line segment from the *loc1* corner of *bbox1* to the *loc2*
corner of *bbox2*.'

@staticmethod
def connect_bbox(bbox1, bbox2, loc1, loc2=None):

    if isinstance(bbox1, Rectangle):
        transform = bbox1.get_transfrom()
        bbox1 = Bbox.from_bounds(0, 0, 1, 1)
        bbox1 = TransformedBbox(bbox1, transform)
    if isinstance(bbox2, Rectangle):
        transform = bbox2.get_transform()
        bbox2 = Bbox.from_bounds(0, 0, 1, 1)
        bbox2 = TransformedBbox(bbox2, transform)
    if (loc2 is None):
        loc2 = loc1
    (x1, y1) = BboxConnector.get_bbox_edge_pos(bbox1, loc1)
    (x2, y2) = BboxConnector.get_bbox_edge_pos(bbox2, loc2)
    verts = [[x1, y1], [x2, y2]]
    codes = [Path.MOVETO, Path.LINETO]
    return Path(verts, codes)
