def METHOD_NAME(intervals, *, closed: bool):
    """
    Generate tuples of (start, end) coordinates for merged intervals.
    """
    intervals = sorted(intervals, key=operator.itemgetter(0))
    if len(intervals) == 0:
        return
    start, end = intervals[0]
    for a, b in intervals[1:]:
        assert a <= b
        if a > end + closed:
            # No intersection with the current interval.
            yield start, end
            start, end = a, b
        else:
            # Intersects, or is contiguous with, the current interval.
            end = max(end, b)
    yield start, end