stats: Add support for hierarchical stats