boolean matchesPrefix(String prefix) {
        // long t0 = System.nanoTime();
        Boolean cached = cache.get(prefix);
        if (cached != null) {
            // System.out.println("prefix: " + (System.nanoTime() - t0));
            return cached.booleanValue();
        }
        Set<String> tailSet = dictionary.tailSet(prefix);
        for (String tail: tailSet) {
            if (tail.startsWith(prefix)) {
                // System.out.println("prefix: " + (System.nanoTime() - t0));
                cache.putIfAbsent(prefix, Boolean.TRUE);
                return true;
            }
        }
        // System.out.println("prefix: " + (System.nanoTime() - t0));
        cache.putIfAbsent(prefix, Boolean.FALSE);
        return false;
    }