sealed class Dumper { static public string Dump(Node root) { return Dump( root, "" ); } static private string Dump(Node node, string indent) { return node.Text + "\n" + node.Children.Take(node.Children.Count - 1) .Aggregate(string.Empty, (results, child) => results + indent + "├─" + Dump(child, indent + "│ ") ) + ( node.Children.Count == 0 ? "" : indent + "└─" + Dump(node.Children.Last(), indent + " " ) ); } }