@Override
    public int lookup(String key){
        if (key == null || key.isEmpty())
            return UNKNOWN_ID;

        CodeSequence cs = thl.get();
        cs.set(key, codemap_);

        int src = ROOT ;
        int pos = 0 ;

        while (pos < cs.size_){
            int dest = Node.BASE(nodes_[src]) + cs.sequence_[pos];
            if (dest < nodes_.length){
                if (src == Node.CHECK(nodes_[dest])){
                    pos ++ ;
                    src = dest;
                    continue;
                }
            }
            int t = Node.TAIL(nodes_[src]);
            if (t >= 0 && tails_.match(t, pos, cs.size_, cs.sequence_))
                return src;
            return UNKNOWN_ID;
        }
        if (Node.TERMINAL(nodes_[src]))
            return src;

        return UNKNOWN_ID;
    }