def search(obj, glob, yielded=False, separator="<STR_LIT:/>", afilter=None, dirs = True):
def _search_view(obj, glob, separator, afilter, dirs):<EOL><INDENT>view = {}<EOL>globlist = __safe_path__(glob, separator)<EOL>for path in _inner_search(obj, globlist, separator, dirs=dirs):<EOL><INDENT>try:<EOL><INDENT>val = dpath.path.get(obj, path, afilter=afilter, view=True)<EOL>merge(view, val)<EOL><DEDENT>except dpath.exceptions.FilteredValue:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return view<EOL><DEDENT>def _search_yielded(obj, glob, separator, afilter, dirs):<EOL><INDENT>globlist = __safe_path__(glob, separator)<EOL>for path in _inner_search(obj, globlist, separator, dirs=dirs):<EOL><INDENT>try:<EOL><INDENT>val = dpath.path.get(obj, path, view=False, afilter=afilter)<EOL>yield (separator.join(map(str, dpath.path.paths_only(path))), val)<EOL><DEDENT>except dpath.exceptions.FilteredValue:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>if afilter is not None:<EOL><INDENT>dirs = False<EOL><DEDENT>if yielded:<EOL><INDENT>return _search_yielded(obj, glob, separator, afilter, dirs)<EOL><DEDENT>return _search_view(obj, glob, separator, afilter, dirs)<EOL>
Given a path glob, return a dictionary containing all keys
that matched the given glob.

If 'yielded' is true, then a dictionary will not be returned.
Instead tuples will be yielded in the form of (path, value) for
every element in the document that matched the glob.