private static void WriteNode(SimpleTreeNode node, StringBuilder sb)
        {
            sb.Append(node.Text);
            if (node is SimpleGroupNode)
            {
                SimpleGroupNode group = (SimpleGroupNode)node;
                sb.Append('(');
                for (int i = 0; i < group.Count; i++)
                {
                    if (i > 0)
                    {
                        sb.Append(',');
                    }

                    WriteNode(group[i], sb);
                }

                sb.Append(')');
            }
        }
 public static string ToParenthesesFormat(SimpleTreeNode tree)
 {
     StringBuilder sb = new StringBuilder();
     WriteNode(tree, sb);
     return sb.ToString();
 }