check a object is parent or not?

i have a object with childs.

During play, according to condition childs get destroy

if object dont have any child it should get destroy.

How can i destroy using


What condition should i write to check

Just use:

if(transform.childCount == 0){

Check also this good answer by skovacs1 for completeness.