transforming sequence of STRING to tree
<p>I have a list of strings with information about how deep they are located in an XML tree. The strings at "the bottom," i.e. those elements that occur before an element with a lower depth, contain text.</p>

<p><code>a_text,b_text,c_text,g1_text,b_text,c_text,g2_text,b_text,g1_text,g2_text,b_text,e_text</code></p>

<p>I would like to reconstitute this as the XML tree below, in one operation.</p>

<pre><code>&lt;AA&gt;
&lt;a&gt;text&lt;/a&gt;
&lt;b&gt;text&lt;/b&gt;
&lt;c&gt;text&lt;/c&gt;
&lt;g1_1&gt;
    &lt;g1&gt;text&lt;/g1&gt;
    &lt;b&gt;text&lt;/b&gt;
    &lt;c&gt;text&lt;/c&gt;
    &lt;g2_2&gt;
        &lt;g2&gt;text&lt;/g2&gt;
        &lt;b&gt;text&lt;/b&gt;
    &lt;/g2_2&gt;
&lt;/g1_1&gt;
&lt;g1_1&gt;
    &lt;g1&gt;text&lt;/g1&gt;
    &lt;b&gt;text&lt;/b&gt;
&lt;/g1_1&gt;
&lt;e&gt;text&lt;/e&gt;&lt;/AA&gt;
</code></pre>