added more code for constructing Huffman shaped wavelet trees