extracting code-tree stuff into a module
successive merge algorithm for generating a huffman encoding tree