def flatten(children=[], **other): if other: yield other for child in children: yield from flatten(**child)