code: def test_nested_create(path=None):
      # to document some more organic usage pattern
      ds = Dataset(path).create()
      assert_repo_status(ds.path)
      lvl2relpath = op.join("lvl1", "lvl2")
      lvl2path = op.join(ds.path, lvl2relpath)
      os.makedirs(lvl2path)
      os.makedirs(op.join(ds.path, "lvl1", "empty"))
      with open(op.join(lvl2path, "file"), "w") as f:
          f.write("some")
      ok_(ds.save())
      # Empty directories are filtered out.
      assert_repo_status(ds.path, untracked=[])
      # later create subdataset in a fresh dir
      # WINDOWS FAILURE IS NEXT LINE
      subds1 = ds.create(op.join("lvl1", "subds"))
      assert_repo_status(ds.path, untracked=[])
      eq_(
          ds.subdatasets(result_xfm="relpaths"),
          [op.join("lvl1", "subds")],
      )
      # later create subdataset in an existing empty dir
      subds2 = ds.create(op.join("lvl1", "empty"))
      assert_repo_status(ds.path)
      # later try to wrap existing content into a new subdataset
      # but that won't work
      assert_in_results(
          ds.create(lvl2relpath, **raw),
          status="error",
          message=(
              "collision with content in parent dataset at %s: %s",
              ds.path,
              [op.join(lvl2path, "file")],
          ),
      )
      # even with force, as to do this properly complicated surgery would need to
      # take place
      # MIH disable shaky test till proper dedicated upfront check is in-place in `create`
      # gh-1725
      # assert_in_results(
      #    ds.create(lvl2relpath, force=True,
      #              on_failure='ignore', result_xfm=None, result_filter=None),
      #    status='error', action='add')
      # only way to make it work is to unannex the content upfront
      ds.repo.call_annex(["unannex", op.join(lvl2relpath, "file")])
      # nothing to save, git-annex commits the unannex itself, but only on v5
      ds.repo.commit()
      # still nothing without force
      # "err='lvl1/lvl2' already exists in the index"
      assert_in_results(
          ds.create(lvl2relpath, **raw),
          status="error",
          message="will not create a dataset in a non-empty directory, use `--force` option to ignore",
      )
      # XXX even force doesn't help, because (I assume) GitPython doesn't update
      # its representation of the Git index properly
      ds.create(lvl2relpath, force=True)
      assert_in(lvl2relpath, ds.subdatasets(result_xfm="relpaths"))
  
imports: import os
  import os.path
  import pytest
  from datalad.api import create
  from datalad.cmd import WitlessRunner
  from datalad.distribution.dataset import Dataset
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.exceptions import CommandError
  from datalad.tests.utils_pytest import OBSCURE_FILENAME, assert_in, assert_in_results, assert_not_in, assert_raises, assert_repo_status, assert_status, eq_, has_symlink_capability, ok_, ok_exists, swallow_outputs, with_tempfile, with_tree
  from datalad.utils import Path, chpwd
label_desc: Use image node_id 10 for calling a global function with example usage: test_nested_create(path) without return types