code: def _get_present_datasets(ds, recursive, recursion_limit):
      """Return list of (sub)dataset instances for all locally present datasets"""
      # gather datasets and essential info
      # dataset instance and mountpoint relative to the top
      toprocess = [ds]
      if recursive:
          for sub in ds.subdatasets(
              # we want to report on missing dataset in here
              state="any",
              recursive=recursive,
              recursion_limit=recursion_limit,
              result_xfm="datasets",
              result_renderer="disabled",
              return_type="generator",
          ):
              if not sub.is_installed():
                  lgr.info("Ignoring unavailable subdataset %s", sub)
                  continue
              toprocess.append(sub)
      return toprocess
  
imports: import logging
  import re
  from urllib.parse import urljoin, urlparse
  import requests
  from datalad import cfg
  from datalad.distribution.dataset import EnsureDataset, require_dataset
  from datalad.downloaders.credentials import Token
  from datalad.downloaders.http import DEFAULT_USER_AGENT
  from datalad.interface.common_opts import publish_depends, recursion_flag, recursion_limit
  from datalad.interface.results import get_status_dict
  from datalad.support.constraints import EnsureChoice, EnsureNone, EnsureStr
  from datalad.support.param import Parameter
  from datalad.ui import ui
  from datalad.utils import todo_interface_for_extensions
label_desc: Use image node_id 3 for calling a global function with example usage: _get_present_datasets(ds, recursive, recursion_limit) and returns: toprocess