private void search(TrieNode node, int row, int col)
    {
        if (row < 0 || row >= rows || col < 0 || col >= cols) {
            return;
        }
        if (visited[row][col]) {
            return;
        }
        
        char boardChar = board[row][col];
        TrieNode next = node.getNext(boardChar);
        if (next == null) {
            return;
        }
        if (next.end != null) {
            result.add(next.end);
        }
        visited[row][col] = true;
        search(next, row, col + 1);
        search(next, row, col - 1);
        search(next, row + 1, col);
        search(next, row - 1, col);
        visited[row][col] = false;
    }