Organise SQLAlchemy models into tree structures, based on the ancestry gem for ActiveRecord.