def METHOD_NAME(key, value, subkey):
    column = AnalysisEntry.result
    if isinstance(value, dict) and '$exists' in value:
        # "$exists" (aka key exists in json document) is a special case because
        # we need to query the element one level above the actual key
        for nested_key in subkey.split('.')[:-1]:
            column = column[nested_key]
    else:
        for nested_key in subkey.split('.'):
            column = column[nested_key]
    if isinstance(value, dict):
        for key_, value_ in value.items():
            if key_ in ['$in', '$like']:
                column = column.astext
                break
            value[key_] = dumps(value_)
    else:
        value = type_coerce(value, JSONB)
    return _dict_key_to_filter(column, key, value)