Searching for a group guid of a component

Hi,

I would like to ask if there is a better way to find if a current component is inside a group?

I am searching through all objects in the grasshopper document and check a) if object is a group b) if a group contains current component guid. I assume looping can be slow.

Is there a simpler way to do this?

            GH_Document ghdoc = base.OnPingDocument();
            for (int i = 0; i < ghdoc.ObjectCount; i++)
            {
                IGH_DocumentObject obj = ghdoc.Objects[i];
                if (obj.Attributes.DocObject.ToString().Equals("Grasshopper.Kernel.Special.GH_Group"))
                {
                    Grasshopper.Kernel.Special.GH_Group groupp = (Grasshopper.Kernel.Special.GH_Group)obj;
                    if (groupp.ObjectIDs.Contains(this.InstanceGuid))
                        return;
                }

            }