This is a mysql and postgresql store procedure and trigger implementation of closure table in RDBMS about hierarchy data model.
Why do you think that https://github.com/aergoio/sqlite-stored-procedures is a good alternative to hierarchy-data-closure-table