using System.Collections.Generic;
using System.Collections.Immutable;
public sealed class Program
private readonly string name;
: this(name, Array.Empty<string>())
public Node(string name, params string[] childNodes)
: this(name, childNodes.Select(s => new Node(s)).ToImmutableList())
private Node(string name, IEnumerable<Node> childNodes)
public IEnumerable<Node> ChildNodes { get; }
public override string ToString()
return $"{nameof(name)}: {name}";
private static IEnumerable<Node> Nodes { get; } = new[]
new Node("image", "raw", "jpeg", "png"),
new Node("video", "mp4"),
new Node("music", "wav", "mp3"),
private static void FixMe()
var list = Nodes.SelectMany(n => n.ChildNodes.Take(1));
public static void Main(string[] args)