SQLAlchemy hierarchical key/value helper