Finish Huffman homework, but bug exists

Bug occurs when the code tree has only one leaf node