I could make my code more space efficient (at runtime only) if the List class provided the member function length that would return the length of the list. Right now, we assume that it is bigger than some predefined constant.
We also think that the optimizer should uniquely identify all the attributes in the tree not only by name (which is string and hard to hash) but by unique ID. This way my code could be faster because I could build the hash table on the available attributes in each plan node and I could compare the attributes easily.