code: def traverse_directory(dir_path, yield_dir=False):
      
      if not os.path.isdir(dir_path):
          return
  
      for item in os.listdir(dir_path):
          new_path = os.path.join(dir_path, item)
          if os.path.isdir(new_path):
              if yield_dir:
                  yield new_path + os.path.sep
              yield from traverse_directory(new_path, yield_dir)
          else:
              yield new_path
docs: Traverse through a directory recursively.
  
      :param dir_path: directory path
      :param yield_dir: yield subdirectory or not
      :return: a generator