turn off parent Gameobject based on a child game object that entered a Trigger?

hey! so i gave this pice of code:

public GameObject player;

 void OnTriggerExit (Collider myTrigger) {
         if(myTrigger.gameObject.tag == "Player"){
             Debug.Log("Box went through!");

             myTrigger.gameObject.SetActive(false);
             isPlayerVisible = false;
         }
     }

that works pretty fine, i get the debug log and so on. what i want to do now is, that the Gameobject that should gets deactivated, is a Parent of the Trigger. so the Hierarchie is:

-MainGO
 --CharacterController
     ---myTrigger(the GO that gets turned off at the moment)

i want to turn off the MainGO

myTrigger.transform.parent.parent.gameObject.SetActive(false); // should do the trick.
With .transform you get your triggers transform component, with .parent you get the parent transform of that (which would be CharacterController), with the second .parent you get the parent transform of that transform (which is MainGO) and with .gameObject you have the GameObject of it on which you can use the SetActive(false);.

myTrigger.transform.parent.parent.gameObject.SetActive(false); // I think :stuck_out_tongue:
//myTrigger.transform.root.SetActive(false); //could work too, it returns the highest in hierarchy.