'Our helper function, which will also recursively check dict and
list entries due to the fact that they may be repr\'d and contain
a key or value which contains jinja2 syntax and would otherwise
lose the AnsibleUnsafe value.'

def _is_unsafe(self, val):

    if isinstance(val, dict):
        for key in val.keys():
            if self._is_unsafe(val[key]):
                return True
    elif isinstance(val, list):
        for item in val:
            if self._is_unsafe(item):
                return True
    elif (isinstance(val, string_types) and hasattr(val, '__UNSAFE__')):
        return True
    return False
