

def _flatten(cls, predicate, *predicates):
    if (not predicates):
        return predicate
    else:
        all_predicates = []
        if isinstance(predicate, cls):
            all_predicates.extend(predicate.predicates)
        else:
            all_predicates.append(predicate)
        for p in predicates:
            if isinstance(p, cls):
                all_predicates.extend(p.predicates)
            else:
                all_predicates.append(p)
        return cls(*all_predicates)

dataset/ETHPy150Open ionelmc/python-hunter/src/hunter/__init__.py _flatten/original