def _get_existing_integration_model_obj(
        self,
        validated_data: dict,  # type: ignore[type-arg]
    ) -> typing.Optional[Model]:
        """
        Get the existing integration model (e.g. MixpanelConfig) for the given one-to-one related
        model (e.g. Environment) if one exists.
        """
        one_to_one_related_obj = validated_data.get(self.one_to_one_field_name)
        return (  # type: ignore[no-any-return]
            self.Meta.model.objects.all_with_deleted()  # type: ignore[attr-defined]
            .filter(**{self.one_to_one_field_name: one_to_one_related_obj})
            .first()
        )

        Get the existing integration model (e.g. MixpanelConfig) for the given one-to-one related
        model (e.g. Environment) if one exists.
        
api/integrations/common/serializers.py