code: def test_recurse_existing(src=None, path=None):
      origin_ds = _make_dataset_hierarchy(src)
  
      # make sure recursion_limit works as expected across a range of depths
      for depth in range(len(origin_ds)):
          res = install(
              path,
              source=src,
              recursive=True,
              recursion_limit=depth,
              result_xfm=None,
              return_type="list",
              result_filter=None,
          )
          # we expect one dataset per level
          assert_result_count(
              res, depth + 1, type="dataset", status="ok"
          )
          rmtree(path)
  
      # now install all but the last two levels, no data
      root, sub1, sub2 = install(
          path,
          source=src,
          recursive=True,
          recursion_limit=2,
          result_xfm="datasets",
          result_filter=None,
      )
      ok_(sub2.repo.file_has_content("file_in_annex.txt") is False)
      sub3 = Dataset(opj(sub2.path, "sub3"))
      ok_(not sub3.is_installed())
      # now get all content in all existing datasets, no new datasets installed
      # in the process
      files = root.get(
          curdir, recursive=True, recursion_limit="existing"
      )
      assert_not_in_results(files, type="dataset", status="ok")
      assert_result_count(files, 1, type="file", status="ok")
      ok_(sub2.repo.file_has_content("file_in_annex.txt") is True)
      ok_(not sub3.is_installed())
      # now pull down all remaining datasets, no data
      sub3, sub4 = root.get(
          curdir,
          recursive=True,
          get_data=False,
          result_xfm="datasets",
          result_filter=lambda x: x["status"] == "ok",
      )
      ok_(sub4.is_installed())
      ok_(sub3.repo.file_has_content("file_in_annex.txt") is False)
      # aaannd all data
      files = root.get(
          curdir,
          recursive=True,
          result_filter=lambda x: x["status"] == "ok"
          and x["type"] == "file",
      )
      eq_(len(files), 1)
      ok_(sub3.repo.file_has_content("file_in_annex.txt") is True)
  
imports: from os import curdir
  from os.path import basename
  from os.path import join
  from unittest.mock import patch
  import pytest
  from datalad.api import clone, create, get, install
  from datalad.distribution.get import _get_flexible_source_candidates_for_submodule
  from datalad.interface.results import only_matching_paths
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.exceptions import InsufficientArgumentsError, RemoteNotAvailableError
  from datalad.support.network import get_local_file_url
  from datalad.tests.utils_testdatasets import _make_dataset_hierarchy, _mk_submodule_annex
  from datalad.tests.utils_pytest import create_tree, assert_false, assert_raises, assert_in, assert_status, assert_in_results, assert_not_in_results, assert_repo_status, assert_result_count, assert_message, DEFAULT_REMOTE, eq_, known_failure_windows, known_failure_githubci_win, ok_, serve_path_via_http, skip_if_adjusted_branch, skip_ssh, skip_if_on_windows, slow, with_tempfile, with_tree
  from datalad.utils import Path, chpwd, rmtree, with_pathsep
  from ..dataset import Dataset
label_desc: Use image node_id 12 for calling a global function with example usage: test_recurse_existing(src, path) without return types