def _get_next_tree_id(self):
        opts = self.model._meta
        cursor = connection.cursor()
        cursor.execute('SELECT MAX(%s) FROM %s' % (
            qn(opts.get_field(self.tree_id_attr).column),
            qn(opts.db_table)))
        row = cursor.fetchone()
        return row[0] and (row[0] + 1) or 1
Determines the next largest unused tree id for the tree managed
dataset/ETHPy150Open agiliq/django-socialnews/socialnews/mptt/managers.py/TreeManager._get_next_tree_id