Huffman coding

I've implemented the generation of a Huffman encoding tree, which first builds a tree and then traverses it to get the encoding. 

I've left copious amounts of comments detailing what I'm doing, but one thing I'm not sure if I'm doing right is my implementation of the `TotalOrd` trait. I feel like it's too long and complicated, and it would be great if you have any suggestions on how to improve that.