@SuppressWarnings("unchecked")
    public B flattenMixins() {
        if (mixins == null || mixins.isEmpty()) {
            return (B) this;
        }

        for (Shape mixin : mixins.values()) {
            // Only inherit non-local traits that aren't already on the shape.
            Map<ShapeId, Trait> nonLocalTraits = MixinTrait.getNonLocalTraitsFromMap(mixin.getAllTraits());
            for (Map.Entry<ShapeId, Trait> entry : nonLocalTraits.entrySet()) {
                if (!traits.hasValue() || !traits.get().containsKey(entry.getKey())) {
                    addTrait(entry.getValue());
                }
            }
        }

        // Don't call clearMixins here because its side effects are unwanted.
        mixins.clear();
        return (B) this;
    }
Removes mixins from a shape and flattens them into the shape.

<p>Flattening a mixin into a shape copies the traits and members of a
mixin onto the shape, effectively resulting in the same shape but with
no trace of the mixin relationship.

@return Returns the updated builder.
smithy-model/src/main/java/software/amazon/smithy/model/shapes/AbstractShapeBuilder.java