def bases_walker(cls):
    """
    Loop through all bases of cls

    >>> str = u'hai'
    >>> for base in bases_walker(unicode):
    ...     isinstance(str, base)
    True
    True

    :param cls: The class in which we want to loop through the base classes.
    """
    for base in cls.__bases__:
        yield base
        for more in bases_walker(base):
            yield more