'Return a list of all classes that are ancestors of *classes*.'

def _all_classes(self, classes):

    all_classes = {}
    def recurse(cls):
        all_classes[cls] = None
        for c in cls.__bases__:
            if (c not in all_classes):
                recurse(c)
    for cls in classes:
        recurse(cls)
    return all_classes.keys()
