def enable_custom_function_prefix(rq, prefix):
    """Add SPARQL prefixe header if the prefix is used in the given query."""
    if ' %s:' % prefix in rq or '(%s:' % prefix in rq and not 'PREFIX %s:' % prefix in rq:
        rq = 'PREFIX %s: <:%s>\n' % (prefix, prefix) + rq
    return rq