def _check_value_recursively(key, val, haystack):
if isinstance(haystack, list):<EOL><INDENT>return any([_check_value_recursively(key, val, l) for l in haystack])<EOL><DEDENT>elif isinstance(haystack, dict):<EOL><INDENT>if not key in haystack:<EOL><INDENT>return any([_check_value_recursively(key, val, d) for k, d in list(haystack.items())<EOL>if isinstance(d, list) or isinstance(d, dict)])<EOL><DEDENT>else:<EOL><INDENT>return haystack[key] == val<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT>
Check if there is key _key_ with value _val_ in the given dictionary.
..warning:
    This is geared at JSON dictionaries, so some corner cases are ignored,
    we assume all iterables are either arrays or dicts