public static Map<ShapeId, Trait> getNonLocalTraitsFromMap(Map<ShapeId, Trait> traits) {
        if (traits.isEmpty() || !traits.containsKey(ID)) {
            return traits;
        }

        Map<ShapeId, Trait> filtered = new HashMap<>(traits);

        // Technically the trait could be a dynamic trait in some wacky,
        // hand-made model that isn't sent through the assembler. That is
        // so beyond unlikely, that a hard cast here works fine.
        MixinTrait mixinTrait = (MixinTrait) traits.get(MixinTrait.ID);

        for (ShapeId toRemove : mixinTrait.getLocalTraits()) {
            filtered.remove(toRemove);
        }

        return filtered;
    }
Helper method used to filter out non-local traits from a map of traits.

<p>If the map is empty or does not contain a mixin trait, then it is
returned as-is. If the map does contain the mixin trait, then a new map
is created that does not contain any of the localTraits specified on
the trait.

@param traits Traits to filter based on the localTraits property of the mixin.
@return Returns the filtered traits.
smithy-model/src/main/java/software/amazon/smithy/model/traits/MixinTrait.java