public String longestPrefixOf(String string)
    {
        if (string == null)
        {
            throw new IllegalArgumentException();
        }
        if (root == null)
        {
            return null;
        }
        int longest = -1;
        if (root.value != null)
        {
            longest = 0;
        }
        Node<V> node = root;
        int length = string.length();
        for (int i = 0; i < length && node != null; ++i)
        {
            char c = string.charAt(i);
            if (!valid(c))
            {
                throw new IllegalArgumentException();
            }
            node = node.next[c];
            if (node.value != null)
            {
                longest = i + 1;
            }
        }
        if (longest == -1)
        {
            return null;
        }
        return string.substring(0, longest);
    }