private static void addShapeAndMembers(String shapeName,
            Map<String, ShapeModel> in,
            Map<String, ShapeModel> out) {

        if (shapeName == null) return;

        final ShapeModel shape = in.get(shapeName);
        if (shape == null) return;

        if (!out.containsKey(shapeName)) {
            out.put(shapeName, in.get(shapeName));
            List<MemberModel> members = shape.getMembers();

            if (members != null) {
                for (MemberModel member : members) {
                    List<String> memberShapes = resolveMemberShapes(member);
                    if (memberShapes == null) continue;
                    for (String memberShape : memberShapes) {
                        addShapeAndMembers(memberShape, in, out);
                    }
                }
            }
        }
    }
Adds the shape. Recursively adds the shapes represented by its members.
aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/RemoveUnusedShapes.java