def Conjunctive(name, bases, attrs):
    """Returns a metaclass that is conjunctive descendant of all metaclasses used by parent
    classes.

    Example:

        class A(type): pass

        class B(type): pass

        class AA(metaclass=A):pass

        class BB(metaclass=B):pass

        class CC(AA, BB, metaclass=Conjunctive): pass
    """
    basemetaclasses = []
    for base in bases:
        metacls = type(base)
        if isinstance(metacls, type) and metacls is not type and not metacls in basemetaclasses:
            basemetaclasses.append(metacls)
    dynamic = type(''.join(b.__name__ for b in basemetaclasses), tuple(basemetaclasses), {})
    return dynamic(name, bases, attrs)