Here are some epub books with hierarchical subgroups. In this case I followed the example in the calibre manual here:
https://manual.calibre-ebook.com/sub_groups.html
A user defined column, Genre/#genre, created in calibre is used in this case.
In books.zip, attached to this posts, are the books with opf:s.
(The books are all from the MobileRead library, polished to reduce size and embed metadata.)