Apply a transform to iterable before flattening at each level.

def xflatten(iterable, transform, check=is_iterable):
    """Apply a transform to iterable before flattening at each level."""
    for value in transform(iterable):
        if check(value):
            for flat in xflatten(value, transform, check):
                yield flat
        else:
            yield value