def iter_bases(bases):
        """
        Performs MRO linearization of a set of base classes.  Yields
        each base class in turn.
        """

        sequences = ([list(inspect.getmro(base)) for base in bases] +
                     [list(bases)])

        # Loop over sequences
        while True:
            sequences = [seq for seq in sequences if seq]
            if not sequences:
                return

            # Select a good head
            for seq in sequences:
                head = seq[0]

                tails = [seq for seq in sequences if head in seq[1:]]
                if not tails:
                    break
            else:
                raise TypeError('Cannot create a consistent method '
                                'resolution order (MRO) for bases %s' %
                                ', '.join([base.__name__ for base in bases]))

            # Yield this base class
            yield head

            # Remove base class from all the other sequences
            for seq in sequences:
                if seq[0] == head:
                    del seq[0]
Performs MRO linearization of a set of base classes.  Yields
        each base class in turn.