def populate_database(self, model, level=1, parents=(None,)):
        n_siblings = self.siblings_per_level[level-1]
        for parent in parents:
            if model in (TreePlace, TreebeardALPlace):
                bulk = [model(parent=parent)
                        for _ in range(n_siblings)]
                model.objects.bulk_create(bulk)
                objects = model.objects.filter(parent=parent)
            elif model in (TreebeardMPPlace, TreebeardNSPlace):
                # We fetch again each parent because the path can change
                # during the creation of children from the previous parent.
                if parent is not None:
                    parent = model.objects.get(pk=parent.pk)
                objects = [model.add_root() if parent is None
                           else parent.add_child() for _ in range(n_siblings)]
            else:
                objects = [model.objects.create(parent=parent)
                           for _ in range(n_siblings)]
            yield model.objects.count()
            if level < len(self.siblings_per_level):
                for count in self.populate_database(model, level+1, objects):
                    yield count
dataset/ETHPy150Open BertrandBordage/django-tree/benchmark/base.py/Benchmark.populate_database/original