Alien Language, some progress

Not a very efficient solution. It worked for the small inputs, but it
scales horribly on large inputs. That's what I get for being lazy. Now,
how can I reduce the amount of dictionary I consider.... maybe a tree
traversal?