private static boolean isValid(TrieNode trie, Rectangle rectangle, boolean checkHasWord) {
        int length = rectangle.getLength();
        if (trie == null) return false;
        for (int i = 0; i < length; ++i) {
            String columnWord = rectangle.getWordByCol(i);
            if (checkHasWord) {
                if (!Trie.hasWord(trie, columnWord)) return false;
            } else {
                if (!Trie.hasPrefix(trie, columnWord)) return false;
            }
        }
        return true;
    }