import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public final class Main {

    public static final class Node {

        private final String name;
        private final List<Node> children;

        public Node(String name) {
            this(name, Collections.emptyList());
        }

        public Node(String name, String... children) {
            this(name, Arrays.stream(children)
                .map(Node::new)
                .collect(Collectors.toUnmodifiableList()));
        }

        private Node(String name, List<Node> list) {
            this.name = name;
            this.children = list;
        }

        public List<Node> getChildNodes() {
            return children;
        }

        @Override
        public String toString() {
            return "name: " + name;
        }
    }

    private static List<Node> getNodes() {
        return List.of(
            new Node("image", "raw", "jpeg", "png"),
            new Node("video", "mp4"),
            new Node("game"),
            new Node("music", "wav", "mp3"));
    }

    private static void fixMe() {
        var list = getNodes().stream()
	        .flatMap(n -> n.getChildNodes().stream().findFirst().stream())
            .collect(Collectors.toList());
        list.forEach(System.out::println);
    }

    public static void main(String[] args) {
        fixMe();
    }
}
