func (t *huffmanTree) Decode(br *bitReader) (v uint16) {
	nodeIndex := uint16(0)  
	for {
		node := &t.nodes[nodeIndex]
		var bit uint16
		if br.bits > 0 {
			br.bits--
			bit = uint16(br.n>>(br.bits&63)) & 1
		} else {
			bit = uint16(br.ReadBits(1))
		}
		l, r := node.left, node.right
		if bit == 1 {
			nodeIndex = l
		} else {
			nodeIndex = r
		}
		if nodeIndex == invalidNodeValue {
			l, r := node.leftValue, node.rightValue
			if bit == 1 {
				v = l
			} else {
				v = r
			}
			return
		}
	}
}
Decode reads bits from the given bitReader and navigates the tree until a
symbol is found.
package bzip2
import "sort"
type huffmanTree struct {
	nodes    []huffmanNode
	nextNode int
}
type huffmanNode struct {
	left, right           uint16
	leftValue, rightValue uint16
}
const invalidNodeValue = 0xffff