check if object has parent unity

Code Example - check if object has parent unity

                
                        if(transform.parent != null)
{

}