private void validateUnions(Model model, List<ValidationEvent> events) {
        UnionTerminatesVisitor visitor = new UnionTerminatesVisitor(model);
        for (UnionShape union : model.getUnionShapes()) {
            // Don't evaluate empty unions since that's a different error.
            if (!union.members().isEmpty() && !union.accept(visitor)) {
                events.add(error(union, "It is impossible to create instances of this recursive union"));
            }
            visitor.reset();
        }
    }
Ensures that list, set, and map shapes are not directly recursive,
meaning that if they do have a recursive reference to themselves,
one or more references that form the recursive path travels through
a structure or union shape. And ensures that structure members are
not infinitely mutually recursive using the required trait.

<p>This check removes an entire class of problems from things like
code generators where a list of itself or a list of maps of itself
is impossible to define.
smithy-model/src/main/java/software/amazon/smithy/model/validation/validators/ShapeRecursionValidator.java