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.Count == 0 ? "" : node.Children.Take(node.Children.Count - 1). Aggregate(string.Empty, (results, child) => results + indent + "├─" + Dump(child, indent + "│ ") ) + indent + "└─" + Dump(node.Children.Last(), indent + " " ) ); } }