code: def _depth_limited_walk(top, max_depth=None):
      '''
      Walk the directory tree under root up till reaching max_depth.
      With max_depth=None (default), do not limit depth.
      '''
      for root, dirs, files in salt.utils.path.os_walk(top):
          if max_depth is not None:
              rel_depth = root.count(os.path.sep) - top.count(os.path.sep)
              if rel_depth >= max_depth:
                  del dirs[:]
          yield (six.text_type(root), list(dirs), list(files)f _depth_limited_walk(top, max_depth=None):
      '''
      Walk the directory tree under root up till reaching max_depth.
      With max_depth=None (default), do not limit depth.
      '''
      for root, dirs, files in salt.utils.path.os_walk(top):
          if max_depth is not None:
              rel_depth = root.count(os.path.sep) - top.count(os.path.sep)
              if rel_depth >= max_depth:
                  del dirs[:]
          yield (six.text_type(root), list(dirs), list(files))
docs: Walk the directory tree under root up till reaching max_depth.
      With max_depth=None (default), do not limit depth.