add support for third-level categories in the visualization tree of a dictionary (this code would need to be generalized for n level of categories at some point); add bunch of comments and make code more readable