using System.Collections.Generic;
public List < Node > Children;
Children = new List < Node > ();
static Node CreateNode(int name) {
node.Name = name.ToString();
static void MaxChildren(Node root) {
if (root == null) return;
if (root.Children.Count > count) {
count = root.Children.Count;
for (int i = 0; i < root.Children.Count; i++) {
MaxChildren(root.Children[i]);
Console.WriteLine(e.Message);
public static void Main() {
Node parent = CreateNode(1);
(parent.Children).Add(CreateNode(2));
(parent.Children).Add(CreateNode(3));
(parent.Children).Add(CreateNode(4));
(parent.Children[0].Children).Add(CreateNode(5));
(parent.Children[0].Children).Add(CreateNode(6));
(parent.Children[2].Children).Add(CreateNode(7));
(parent.Children[2].Children).Add(CreateNode(8));
(parent.Children[2].Children).Add(CreateNode(9));
(parent.Children[2].Children).Add(CreateNode(10));
Console.WriteLine("Node {0} has max children with count {1}", maxNode.Name, maxNode.Children.Count);