def METHOD_NAME(f):
    """Decorator to check if schema exists by name and/or version."""
    @wraps(f)
    def wrapper(*args, **kwargs):
        name = kwargs.get('name')
        version = kwargs.get('version')
        if name:
            try:
                if version:
                    schema = Schema.get(name, version)
                else:
                    schema = Schema.get_latest(name)
                kwargs['schema'] = schema
            except JSONSchemaNotFound:
                return (
                    jsonify(
                        {
                            'message': 'Schema not found. Please try '
                            'again with existing schemas.'
                        }
                    ),
                    404,
                )
        return f(*args, **kwargs)
    return wrapper