def bound_elems(elems):
    """
    Finds the minimal bbox that contains all given elems
    """
    group_x0 = min(map(lambda l: l.x0, elems))
    group_y0 = min(map(lambda l: l.y0, elems))
    group_x1 = max(map(lambda l: l.x1, elems))
    group_y1 = max(map(lambda l: l.y1, elems))
    return (group_x0, group_y0, group_x1, group_y1)
Finds the minimal bbox that contains all given elems