code: def walk_files(path, allowed_extensions=None):
      if not os.path.exists(path):
          return
  
      if allowed_extensions is not None:
          allowed_extensions = set(allowed_extensions)
  
      items = list(os.walk(path, followlinks=True))
      items = sorted(items, key=lambda x: natural_sort_key(x[0]))
  
      for root, _, files in items:
          for filename in sorted(files, key=natural_sort_key):
              if allowed_extensions is not None:
                  _, ext = os.path.splitext(filename)
                  if ext not in allowed_extensions:
                      continue
  
              if not shared.opts.list_hidden_files and (
                  "/." in root or "\\." in root
              ):
                  continue
  
              yield os.path.join(root, filename)
  
file_path: stable-diffusion-webui/modules/util.py
imports: import os
  import re
  from modules import shared
  from modules.paths_internal import script_path
label_desc: Use image node_id 5 for calling a global function with example usage: walk_files(path, allowed_extensions) without return types