code: def _expand_directories(paths):
      
      for path in paths:
          path_ = Path(path)
          if path_.is_dir():
              for expanded in path_.rglob('*'):
                  yield str(expanded)
          else:
              yield path
docs: Expand directory with all files it contains.