Instantiation of tree-like structures

There are places in code where we want to instantiate some tree-like structure - mainly while generating HTMLs or/and XMLs. And like always, we've got a few possible solutions.

Constructor
```language-csharp
public class TreeNode  
{
    public string Name { get; }
    public ICollection<TreeNode> SubTrees { get; }
    public TreeNode(string name, IEnumerable<TreeNode> subTrees){
        SubTrees = subNodes.ToList();
    }

    public static TreeNode Empty = new TreeNode[0];
}

Then simple tree can be created with following code:

var tree = new TreeNode(  
    "Root",
    new [] {
        new TreeNode(
            "Category1",
            TreeNode.Empty
        ),
        new TreeNode(
            "Category2",
            new[] {
              new TreeNode(
                  "Category2.1",
                  TreeNode.Empty
              ),
              new TreeNode(
                  "Category2.2",
                  TreeNode.Empty
              ),                
            }
        )
    }
);

The code is obvious, but it gets a lil' bit too long for indentation level higher than 2-3.

Fluent API

Let's introduce a second constructor and a method that will add a node to the tree.

    public TreeNode(string name){
        SubTrees = new List<TreeNode>();
    }
    public TreeNode WithSubTree(TreeNode subTree){
        SubTrees.Add(subTree);
        return this;
    }

Now we can add nodes using fluent method chaining:

var tree = new TreeNode("Root")  
            .WithSubTree(
                new TreeNode("Category1")
                new TreeNode("Category2")
                    .WithSubTree(new TreeNode("Category2.1"))
                    .WithSubTree(new TreeNode("Category2.2"))

The weird looking "new [] " statements got eliminated. Also, we can modify the tree in run-time. But still there is a lot of "new"s.

Lambdas

Delegates to the rescue. We can implement local delegates that encapsulate creation of TreeNode.

Func<string, TreeNode[]> n = (name, subTree => new TreeNode(name, subTree);  
Func<string> leaf = (name) => new TreeNode(name);  

Now we end up with really clean syntax:

var tree = n("Root",  
                leaf("Category1"),
                   n("Category2",
                    leaf("Category2.1"),
                    leaf("Category2.2")
                )
            );

The only drawback is that we have to differentiate nodes between leafs and those with children.

Using static

From C# 6.0 we can use using static statement to tell the complier that we are going to use static members of the given class without the class prefix. Thanks to that feature we can move lambda implementation to the helper class, change it to use params keyword with last parameter and finally specify it with using static in the file where we actually using it.
The helper static class implemetation:

public static class TreeNodeHelpers  
{
    public static TreeNode n(string name, params TreeNode[] subTree)
    {
        return new TreeNode(name, subTree);
    }
}

Then add:

using static SomeNamespace.TreeNodeHelper;  

And use(in the same file):

var tree = n("Root",  
                n("Category1"),
                   n("Category2",
                    n("Category2.1"),
                    n("Category2.2")
                )
            );

We have finally end up with pretty, concise syntax and reusable helpers that can be used project-wide.
How do you like it?
Farewell!