You can do this more simply with `CRM_Core_PseudoConstant::getKey`