WaveletTree implementation