private static int findClosingParenIndex(byte[] filter, int start, int end) {
        int depth = 1;
        boolean escape = false;
        int closingParenIndex = start;
        while (closingParenIndex < end && depth > 0) {
            char c = (char) filter[closingParenIndex];
            if (!escape) {
                if (c == '(') {
                    depth++;
                } else if (c == ')') {
                    depth--;
                }
            }
            escape = c == '\\' && !escape;
            if (depth > 0) {
                closingParenIndex++;
            }
        }
        if (depth != 0) {
            throw new LdapException(ResultCode.FILTER_ERROR, "Unbalanced parenthesis");
        }
        return closingParenIndex;
    }
@author James Chen
@implSpec <a href="https://tools.ietf.org/html/rfc4515"> RFC 4515: String Representation of
          Search Filters</a>
turms-gateway/src/main/java/im/turms/gateway/infra/ldap/element/operation/search/Filter.java