def expand_paths(path, only_python=True):<EOL>
if path is not None and (<EOL>isinstance(path, Sequence)<EOL>and not getattr(path.__class__, "<STR_LIT>", "<STR_LIT>") == "<STR_LIT>"<EOL>):<EOL><INDENT>for p in unnest(path):<EOL><INDENT>if p is None:<EOL><INDENT>continue<EOL><DEDENT>for expanded in itertools.chain.from_iterable(<EOL>expand_paths(p, only_python=only_python)<EOL>):<EOL><INDENT>yield expanded<EOL><DEDENT><DEDENT><DEDENT>elif path is not None and path.is_dir:<EOL><INDENT>for p in path.children.values():<EOL><INDENT>if p is not None and p.is_python and p.as_python is not None:<EOL><INDENT>for sub_path in itertools.chain.from_iterable(<EOL>expand_paths(p, only_python=only_python)<EOL>):<EOL><INDENT>yield sub_path<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if path is not None and path.is_python and path.as_python is not None:<EOL><INDENT>yield path<EOL><DEDENT><DEDENT>
Recursively expand a list or :class:`~pythonfinder.models.path.PathEntry` instance

:param Union[Sequence, PathEntry] path: The path or list of paths to expand
:param bool only_python: Whether to filter to include only python paths, default True
:returns: An iterator over the expanded set of path entries
:rtype: Iterator[PathEntry]