sqlamp is an implementation of an efficient algorithm for working with hierarchical data structures — Materialized Path. sqlamp uses (and depends of) SQLAlchemy. https://github.com/sontek/sqlalchemy_traversal  http://sqlamp.angri.ru/  https://github.com/monetizeio/sqlalchemy-orm-tree  http://docs.sqlalchemy.org/en/rel_0_9/orm/relationships.html#adjacency-list-relationships