def does_model_contain_mlprogram(model) -> bool:
            """
            Is this an mlprogram or is it a pipeline with at least one mlprogram?
            """
            model_type = model.WhichOneof("Type")

            if model_type == "mlProgram":
                return True
            elif model_type not in ("pipeline", "pipelineClassifier", "pipelineRegressor"):
                return False

            # Does this pipeline contain an mlprogram?
            if model_type == "pipeline":
                pipeline_models = model.pipeline.models
            elif model_type == "pipelineClassifier":
                pipeline_models = model.pipelineClassifier.pipeline.models
            else:
                assert model_type == "pipelineRegressor"
                pipeline_models = model.pipelineRegressor.pipeline.models

            for m in pipeline_models:
                if does_model_contain_mlprogram(m):
                    return True
            return False

            Is this an mlprogram or is it a pipeline with at least one mlprogram?
            
coremltools/models/model.py