(Solved) Findout if an object exist in the scene, but dont trow exception

Hi! my question is simple

i want to check if an object in the scene exist, i know how to do that, but, from that, if the object is not found, i want to set a variable to false, but unity of course will trow a null reference exception and my code wont run, is there a way to tell if an object is not present wihtout unity trowing exceptions? this is for editor window scripting btw.

here is the code i have until now

private void CheckIfPrefabHierarchyExist()
    {
        Transform holder = GameObject.Find("Bacterias").transform;
  
        if (holder == null)
        {
            hierarchyPrefabDetected = false;
        }
        else
        {
            hierarchyPrefabDetected = true;
        }
    }

you are getting a null reference exception because your code is trying to return the transform of an object which doesn’t exist.
Try this:

private void CheckIfPrefabHierarchyExist()
{
    if (GameObject.Find("Bacterias") == null)
    {
        hierarchyPrefabDetected = false;
    }
    else
    {
        hierarchyPrefabDetected = true;
    }
}