def paths(obj, dirs=True, leaves=True, path=[], skip=False):
if isinstance(obj, MutableMapping):<EOL><INDENT>if PY3:<EOL><INDENT>iteritems = obj.items()<EOL>string_class = str<EOL><DEDENT>else: <EOL><INDENT>iteritems = obj.iteritems()<EOL>string_class = basestring<EOL><DEDENT>for (k, v) in iteritems:<EOL><INDENT>if issubclass(k.__class__, (string_class)):<EOL><INDENT>if (not k) and (not dpath.options.ALLOW_EMPTY_STRING_KEYS):<EOL><INDENT>raise dpath.exceptions.InvalidKeyName("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>elif (skip and k[<NUM_LIT:0>] == '<STR_LIT:+>'):<EOL><INDENT>continue<EOL><DEDENT><DEDENT>newpath = path + [[k, v.__class__]]<EOL>validate(newpath)<EOL>if dirs:<EOL><INDENT>yield newpath<EOL><DEDENT>for child in paths(v, dirs, leaves, newpath, skip):<EOL><INDENT>yield child<EOL><DEDENT><DEDENT><DEDENT>elif isinstance(obj, MutableSequence):<EOL><INDENT>for (i, v) in enumerate(obj):<EOL><INDENT>newpath = path + [[i, v.__class__]]<EOL>if dirs:<EOL><INDENT>yield newpath<EOL><DEDENT>for child in paths(obj[i], dirs, leaves, newpath, skip):<EOL><INDENT>yield child<EOL><DEDENT><DEDENT><DEDENT>elif leaves:<EOL><INDENT>yield path + [[obj, obj.__class__]]<EOL><DEDENT>elif not dirs:<EOL><INDENT>yield path<EOL><DEDENT>
Yield all paths of the object.

    Arguments:

    obj -- An object to get paths from.

    Keyword Arguments:

    dirs -- Yield intermediate paths.
    leaves -- Yield the paths with leaf objects.
    path -- A list of keys representing the path.
    skip -- Skip special keys beginning with '+'.