Huffman encoding done in Scala