code: def get_git_root_parent_directory(path, input_path):
      """
      This function will recursively go through parent directories until a git
      repository is found or until no parent directories are left, in which case
      an error will be raised. This is needed when providing a path to a
      file/folder that is located on a branch/tag not currently checked out.
  
      Args:
          path: (str) Path a to a directory that is located inside the repo
          input_path: (str) origin path, used when raising WorkflowError
      Returns:
          path to the root folder for git repo
      """
      import git
  
      try:
          git_repo = git.Repo(path, search_parent_directories=True)
          return git_repo.git.rev_parse("--show-toplevel")
      except git.exc.NoSuchPathError:
          tail, _ = os.path.split(path)
          if tail is None:
              raise WorkflowError(
                  f"Neither provided git path ({input_path}) "
                  + "or parent directories contain a valid git repo."
              )
          else:
              return get_git_root_parent_directory(tail, input_path)
  
imports: import os
  import re
  from snakemake.exceptions import WorkflowError
label_desc: Use image node_id 3 for calling a global function with example usage: get_git_root_parent_directory(path, input_path) and returns: git_repo, get_git_root_parent_directory