Model transform(ModelTransformer transformer, Model model) {
        Model.Builder builder = model.toBuilder();

        // Iteratively add each shape that needs to be removed from the index using multiple rounds.
        Set<Shape> removed = new HashSet<>(toRemove);
        for (Shape removedShape : toRemove) {
            validateShapeCopiedFromMixin(model, removedShape);
            builder.removeShape(removedShape.getId());
            // We don't need to remove members from the builder since
            // members are automatically removed with the container.
            removed.addAll(removedShape.members());
        }

        Model result = builder.build();

        for (ModelTransformerPlugin plugin : plugins) {
            result = plugin.onRemove(transformer, removed, result);
        }

        return result;
    }
Removes shapes from a model while ensuring that relationships to/from
the shape are cleaned up.

<p>When a list, set, map, structure, or union are removed,
their member shapes are also removed.

<p><strong>Important</strong>: the removal of list, set, and map members
without removing their containers will leave the model in an inconsistent
state. The appropriate way to remove these shapes is to remove their
containing shape rather than the member.
smithy-model/src/main/java/software/amazon/smithy/model/transform/RemoveShapes.java