code: def find_root(cls, root=None, fs=None) -> str:
      from dvc.fs import LocalFileSystem, localfs
  
      fs = fs or localfs
      root = root or os.curdir
      root_dir = fs.abspath(root)
  
      if not fs.isdir(root_dir):
          raise NotDvcRepoError(f"directory '{root}' does not exist")
  
      while True:
          dvc_dir = fs.join(root_dir, cls.DVC_DIR)
          if fs.isdir(dvc_dir):
              return root_dir
          if isinstance(fs, LocalFileSystem) and os.path.ismount(
              root_dir
          ):
              break
          parent = fs.parent(root_dir)
          if parent == root_dir:
              break
          root_dir = parent
  
      msg = "you are not inside of a DVC repository"
  
      if isinstance(fs, LocalFileSystem):
          msg = f"{msg} (checked up to mount point '{root_dir}')"
  
      raise NotDvcRepoError(msg)
  
imports: import os
  from collections import defaultdict
  from contextlib import contextmanager
  from functools import wraps
  from typing import TYPE_CHECKING, Callable, ContextManager, Iterable, Optional, Tuple, Union
  from dvc.exceptions import DvcException, NotDvcRepoError, OutputNotFoundError, RevCollectionError
  from dvc.ignore import DvcIgnoreFilter
  from dvc.log import logger
  from dvc.utils.objects import cached_property
label_desc: Use image node_id 21 for calling the Repo obj's underlying member method code with example usage: obj.find_root(cls, root, fs) and returns: root_dir