So, quite often I'll come across a situation where I'd like to process hostnames in a hierarchical manner.
For example, given a hostname "foo.bar.baz.example.com", I might want to compare it against a data structure that contains a higher authority like "example.com" or "baz.example.com" and see if I get a match.
Usually, the way I handle this is to simply use a hashtable, and iteratively remove subdomains until I find a match (or, never find a match, whatever the case may be.)
But, I was thinking that something like a trie/prefix-tree might be a lot better suited for this (if I were to reverse the domain labels).
Of course, the problem is that a trie usually works on individual characters - whereas in this case I'd want to make each subdomain (or "label", in DNS-speak), a single "unit".
Is there a data-structure that might be well suited for something like this?