static class Dumper
{
static public string Dump(Node root)
{
return Dump(root, "");
}
static private string Dump(Node root, string indent)
{
string result = root.Text;
for (int i = 0; i < root.Children.Count; i++)
{
bool isLastNode = (i == root.Children.Count - 1);
result += "\n";
result += indent;
result += isLastNode ? "└─" : "├─";
result += Dump(root.Children[i], indent + (isLastNode ? " " : "│ "));
}
return result;
}
}