protected static int findClosingBracket(String str, int fromIndex) {
        int count = 0;
        int i = fromIndex;
        do {
            i++;
            if (i >= str.length()) {
                return -1;
            }
            switch (str.charAt(i)) {
                case ']':
                    count++;
                    break;
                case '[':
                    count--;
                    break;
            }
        } while (count != 0);

        return i;
    }