So I've been putting together a mod that, among other things, features 16 religions (yeah, I know, but it's for a purpose

). And for one type of strategy in the mod it's important to get all 16 religions in your cities...but obviously, that seriously overcrowds the city's name bar. So my idea is something like this:
Every religion would be part of a "pair," (e.g., Judaism+Zoroastrianism, Christianity+Islam, Confucianism+Taoism, etc), and when both members of a pair are present in a city, instead of showing both icons for both religions, it
instead shows a new icon that signifies that pair's presence. Just for crowding's sake. This way, even if all 16 religions are present, there are only 8 total "pair" icons.
If possible, I'd like to make pairs of pairs also, so two fitting pairs would combine into another icon (so only 4 total icons in a city with all 16), and then one single meta icon to signify the presence of all 16 religions.
Anyway...anyone got any thoughts as to how to do something like that? My first guess is that python could make something like that work, but I'm just not good enough at it at all yet.