add_host/group_by how to do sub-groups

Hi,

I’m exploring the use of add_host instead of a rather convoluted dynamic inventory setup. I can create the groups for each host, either by specifying groups in add_host, or using group_by. However, these only create flat, first-level groups. Now I need to have a group hierarchy (group of groups). Some of the group names are created dynamically, so I can’t pre-load the inventory with the group organization.

How can a group of groups be created in the same way as group_by creates groups?
Put another way: how do I add a group to a group inside a playbook?

Thanks,