Basically, you want to map root box names to struct objects. As per the hint from Perl's hash variables, one way is to hash these names as strings so that they become indices in some kind of hash table that serves as a map. Another way is to construct a balanced binary tree using the names, though these have different tradeoffs, e.g., in time complexity.