It would probably be good to define module level constants `HIERARCHICAL = 'h'` and `GROUP = 'g'` (or even use a class attributes, to scope them better), rather than having these string literals littering the code.