def merge_bbox(bboxes):
    """
    Merge bounding boxes.

    Arguments:
        bboxes: iterator of bbox tuples.

    Returns:
        An encompassing bbox.
    """
    minx, miny = [], []
    maxx, maxy = [], []
    for a, b, c, d in bboxes:
        minx.append(a)
        miny.append(b)
        maxx.append(c)
        maxy.append(d)
    return (min(minx), min(miny), max(maxx), max(maxy))