Scala Huffman code