This one is stored per library, along with a lot of others. You can see which by looking at the "preferences" table in metadata.db. The preference you are asking about is
Code:
self.db.prefs.get('categories_using_hierarchy', [])
This works with both new and old API db objects