How To "Not" Make Child Through Script

I couldn’t find a better title.

I have a script which makes object1 child of object2:

if(sth){
   object2.transform.parent = object1.transform;
}

and it works well.

But I have no idea how to make object1 “not child” again?

It must be pretty easy I know, but I’m new to this.

Do I use sth like “!=” ?

object2.transform.parent = null

Many of these sorts of things are available in the manual. Look at the last example for Transform.parent for example.