def flatten(seq, follow=is_seqcont):
    """Flattens arbitrary nested sequence.
       Unpacks an item if follow(item) is truthy."""
    for item in seq:
        if follow(item):
            yield from flatten(item, follow)
        else:
            yield item
Flattens arbitrary nested sequence.
       Unpacks an item if follow(item) is truthy.
funcy/seqs.py