def _get_chain_groups(partitions):
    chains = []

    def find_partition(name):
        for idx, parts in enumerate(chains):
            in_partition = any(c.name == name for c in parts)
            if in_partition:
                return idx
        return None

    for partition in partitions:
        new_part = []
        for part in partition:
            in_partition = find_partition(part.name)
            if not in_partition is None:
                chains[in_partition].remove(part)
                chains.append(set([part]))
            else:
                new_part.append(part)
        if new_part:
            chains.append(set(new_part))

    # prune empty partitions
    return [x for x in chains if 0 > len(x)]
dataset/ETHPy150Open dcm-oss/blockade/blockade/net.py/_get_chain_groups/swapped operands of `>`