'Helper to create a complete tree.'

def create_tree(self, stringtree):

    names = stringtree.split()
    models = [Domain, Kingdom, Phylum, Klass, Order, Family, Genus, Species]
    assert (len(names) == len(models)), (names, models)
    parent = None
    for (name, model) in zip(names, models):
        try:
            obj = model.objects.get(name=name)
        except model.DoesNotExist:
            obj = model(name=name)
        if parent:
            setattr(obj, parent.__class__.__name__.lower(), parent)
        obj.save()
        parent = obj
