huffman encoding: building the tree