Top level of game objects in the inspector

How can I control visibility/activation of game objects in the inspector with code. I was looking at selection…

http://docs.unity3d.com/Documentation/ScriptReference/Selection.html

but that seems to go the other way, if I already have them selected. I have created a List<> of game objects and I want to accomplish the same affect as checking and un-checking the top checkbox in the inspector. Thanks.

Look up Transform.root in the docs.

For each selected transform, find root transform, get its GameObject and toggle it.