private Shape filterTraits(Shape shape) {
        List<Trait> keepTraits = shape.getAllTraits()
                .values()
                .stream()
                .filter(trait -> predicate.test(shape, trait))
                .collect(Collectors.toList());

        return keepTraits.size() == shape.getAllTraits().size()
                ? shape
                : Shape.shapeToBuilder(shape).clearTraits().addTraits(keepTraits).build();
    }
Filters traits out of the Model that do not match a predicate that
accepts the shape that the trait is attached to and the trait.

<p>Shapes are only modified and replaced into the model if one of their
traits are modified.

@see ModelTransformer#filterTraits(Model, BiPredicate)
smithy-model/src/main/java/software/amazon/smithy/model/transform/FilterTraits.java