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