'Returns a list of parent classes leading to \'model\' (order from closet
to most distant ancestor). This has to handle the case were \'model\' is
a granparent or even more distant relation.'

def get_base_chain(self, model):

    if (not self.parents):
        return None
    if (model in self.parents):
        return [model]
    for parent in self.parents:
        res = parent._meta.get_base_chain(model)
        if res:
            res.insert(0, parent)
            return res
    return None
