private static void pruneShapeMembers(ServiceModel serviceModel) {
        Map<String, Shape> shapes = copy(serviceModel.getShapes());
        serviceModel.getShapes().forEach((shapeName, shape) -> {

            Map<String, Member> members = copy(shape.getMembers());
            for (Entry<String, Member> entry : shape.getMembers().entrySet()) {
                String memberName = entry.getKey();
                Member member = entry.getValue();
                if (!shapes.containsKey(member.getShape())) {
                    if (shape.getRequired().contains(memberName)) {
                        // If member is required, remove the entire containing shape
                        shapes.remove(shapeName);
                        log("Pruned shape [%s] with required member [%s]", shapeName, memberName);
                        // Skip these rest of these members & continue to the next shape
                        break;
                    } else {
                        // If member is optional, just remove the member
                        members.remove(memberName);
                        log("Pruned optional member [%s] from shape [%s]", memberName, shapeName);
                        // If the containing shape had a payload referencing this member, remove the payload trait
                        if (memberName.equals(shape.getPayload())) {
                            shape.setPayload(null);
                            log("Pruned payload trait for member [%s] from shape [%s]", memberName, shapeName);
                        }
                    }
                }
            }
            shape.setMembers(members);

        });
        serviceModel.setShapes(shapes);
    }
Prune members that reference pruned shapes.
<p>
If a member is required, we also prune the containing struct, because this implicitly
means that member was added as part of a new struct, which we do not wish to support.
<p>
If a member is optional, this may mean it was added to an existing struct,
so we bias towards removing the member only.
aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/customization/processors/PruneUnsupportedShapesProcessor.java