code: def walk(filesystem, top, topdown=True, onerror=None, followlinks=False):
      
  
      def do_walk(top_dir, top_most=False):
          top_dir = filesystem.normpath(top_dir)
          if not top_most and not followlinks and filesystem.islink(top_dir):
              return
          try:
              top_contents = _classify_directory_contents(filesystem, top_dir)
          except OSError as exc:
              top_contents = None
              if onerror is not None:
                  onerror(exc)
  
          if top_contents is not None:
              if topdown:
                  yield top_contents
  
              for directory in top_contents[1]:
                  if not followlinks and filesystem.islink(directory):
                      continue
                  for contents in do_walk(filesystem.joinpaths(top_dir,
                                                               directory)):
                      yield contents
  
              if not topdown:
                  yield top_contents
  
      return do_walk(top, top_most=True)
docs: Perform an os.walk operation over the fake filesystem.
  
      Args:
          filesystem: The fake filesystem used for implementation
          top: The root directory from which to begin walk.
          topdown: Determines whether to return the tuples with the root as
              the first entry (`True`) or as the last, after all the child
              directory tuples (`False`).
        onerror: If not `None`, function which will be called to handle the
              `os.error` instance provided when `os.listdir()` fails.
        followlinks: If `True`, symbolic links are followed.
  
      Yields:
          (path, directories, nondirectories) for top and each of its
          subdirectories.  See the documentation for the builtin os module
          for further details.