'Finds all class with same master_class as new_class in class tree
and replaces them by new_class.
:param new_class: Class for replacing.'

@classmethod
def _switch_by_class(cls, new_class):

    def find_replace_class(bases):
        for base in bases:
            if ((VersionableClass in base.__bases__) and (base.master_class == new_class.master_class)):
                bnew = list(bases)
                bnew[bnew.index(base)] = new_class
                return tuple(bnew)
            else:
                bnew = find_replace_class(base.__bases__)
                if bnew:
                    base.__bases__ = bnew
    bnew = find_replace_class(cls.__bases__)
    if bnew:
        cls.__bases__ = bnew
