Q:

searching for an attribute group

This is my inefficent code for searching for an attribute group. Can anyone help me come up with a more efficient method. I know I want to use a model that supports addAttributeToFilter or similar.
function Group_Exists($group_name, $set_magento_id)
{
    $attributeSetCollection =             
         Mage::getResourceModel('eav/entity_attribute_group_collection')
                                   ->load();

    foreach ($attributeSetCollection as $id=>$attributeGroup) {
        if ( $attributeGroup->getAttributeGroupName() == $group_name &&
             $attributeGroup->getAttributeSetId() == $set_magento_id )
        {
             return $attributeGroup->getAttributeGroupId();
        }
    }

}

A:

The following should allow you to filter by group name and set it.
/** @var Mage_Eav_Model_Resource_Entity_Attribute_Group_Collection $oEntityAttributeGroup */
$oEntityAttributeGroup = Mage::getResourceModel('eav/entity_attribute_group_collection');
$oEntityAttributeGroup->addFieldToFilter('attribute_group_name', 'Group Name Goes Here');
$oEntityAttributeGroup->addFieldToFilter('attribute_set_id', 'Set Id Goes Here');

Then you can loop through the collection to get all groups that match these settings.

