I know that in Magento 1.4.2.0 one gets parent id\'s like so
list( $parentId ) = Mage::getModel(\'catalog/product_type_configurable\')
You could check the type of the product with $_product->getTypeId(); and if this returns 'configurable', take the configurable model and if it returns 'grouped' take the grouped model.
$_product->getTypeId();
Hope this helps.