code: def get_tcia_ref_uid(
      ds: Iterable,
      find_sop: bool = False,
      ref_series_uid_tag: tuple = (0x0020, 0x000E),
      ref_sop_uid_tag: tuple = (0x0008, 0x1155),
  ) -> str:
      """
      Achieve the referenced UID from the referenced Series Sequence for the input pydicom dataset object.
      The referenced UID could be Series Instance UID or SOP Instance UID. The UID will be detected from
      the data element of the input object. If the data element is a sequence, each dataset within the sequence
      will be detected iteratively. The first detected UID will be returned.
  
      Args:
          ds: a pydicom dataset object.
          find_sop: whether to achieve the referenced SOP Instance UID.
          ref_series_uid_tag: tag of the referenced Series Instance UID.
          ref_sop_uid_tag: tag of the referenced SOP Instance UID.
  
      """
      ref_uid_tag = ref_sop_uid_tag if find_sop else ref_series_uid_tag
      output = ""
  
      for elem in ds:
          if elem.VR == "SQ":
              for item in elem:
                  output = get_tcia_ref_uid(item, find_sop)
          if elem.tag == ref_uid_tag:
              return elem.value  # type: ignore[no-any-return]
  
      return output
  
file_path: MONAI/monai/apps/tcia/utils.py
imports: from __future__ import annotations
  import os
  from typing import Iterable
  import monai
  from monai.config.type_definitions import PathLike
  from monai.utils import optional_import
label_desc: Use image node_id 3 for calling a global function with example usage: get_tcia_ref_uid(ds, find_sop, ref_series_uid_tag, ref_sop_uid_tag) and returns: output, elem