def flatten_iterator(x):

    for elem in x:
        if hasattr(elem, '__iter__'):
            for y in flatten_iterator(elem):
                yield y
        else:
            yield elem
Given an iterator of which further sub-elements may also be
dataset/ETHPy150Open ralfonso/theory/theory/model/mpdutil.py/flatten_iterator