@Override
        public Void listShape(ListShape shape) {
            if (nestedLevel == 0) {
                writer.write("$L.stream().map(s -> $C).collect($T.collect())",
                        varName,
                        (Runnable) () -> shape.getMember().accept(new ToNodeMapperVisitor("s", nestedLevel + 1)),
                        ArrayNode.class);
            } else {
                writer.write("$L.stream().map($L -> $C).collect($T.collect())",
                        varName,
                        "s" + nestedLevel,
                        (Runnable) () -> shape.getMember()
                                .accept(new ToNodeMapperVisitor("s" + nestedLevel,
                                        nestedLevel + 1)),
                        ArrayNode.class);
            }

            return null;
        }
Determines how to map a shape to a node.
smithy-trait-codegen/src/main/java/software/amazon/smithy/traitcodegen/generators/ToNodeGenerator.java