code: def _get_original_parent(
      reverse_transformation: Callable[[Trial], Trial],
      transformed_registry: Registry,
      transformed_trial_parent_id: str,
  ) -> Trial:
      """Get the parent trial in original space based on parent id in transformed_space.
  
      If the parent trial also has a parent, then this function is called recursively
      to set the proper parent id in original space rather than transformed space.
      """
      try:
          transformed_parent = transformed_registry[
              transformed_trial_parent_id
          ]
      except KeyError as e:
          raise KeyError(
              f"Parent trial with id {transformed_trial_parent_id} is not registered in the "
              f"algorithm's registry."
          ) from e
      original_parent = reverse_transformation(transformed_parent)
      # NOTE: This 'reverse' copies the parent property.
      assert original_parent.parent == transformed_parent.parent
      if transformed_parent.parent is not None:
          original_grand_parent = _get_original_parent(
              reverse_transformation=reverse_transformation,
              transformed_registry=transformed_registry,
              transformed_trial_parent_id=transformed_parent.parent,
          )
          original_parent.parent = original_grand_parent.id
      return original_parent
  
imports: from __future__ import annotations
  import copy
  import typing
  from abc import ABC, abstractmethod
  from logging import getLogger
  from typing import Any, Callable
  from orion.algo.base.registry import Registry, RegistryMapping
  from orion.algo.space import Space
  from orion.core.worker.algo_wrappers.algo_wrapper import AlgoT, AlgoWrapper
  from orion.core.worker.transformer import ReshapedSpace, TransformedSpace
  from orion.core.worker.trial import Trial
label_desc: Use image node_id 1 for calling a global function with example usage: _get_original_parent(reverse_transformation, transformed_registry, transformed_trial_parent_id) and returns: original_parent