private void addCode(int sym, int code, byte len) {
        Node terminal = new Node(sym, len);

        Node current = root;
        while (len > 8) {
            len -= 8;
            int i = ((code >>> len) & 0xFF);
            if (current.children == null) {
                throw new IllegalStateException("invalid dictionary: prefix not unique");
            }
            if (current.children[i] == null) {
                current.children[i] = new Node();
            }
            current = current.children[i];
        }

        int shift = 8 - len;
        int start = (code << shift) & 0xFF;
        int end = 1 << shift;
        for (int i = start; i < start + end; i++) {
            current.children[i] = terminal;
        }
    }
This class was originally composed from the following classes in <a
href="https://github.com/twitter/hpack">Twitter Hpack</a>.
<p>
<ul>
<li>{@code com.twitter.hpack.HuffmanEncoder}</li>
<li>{@code com.twitter.hpack.HuffmanDecoder}</li>
<li>{@code com.twitter.hpack.HpackUtil}</li>
</ul>
netbare-core/src/main/java/com/github/megatronking/netbare/http2/Huffman.java