title: Delete Node of BOOST Spirit AST Tree
body: <p>I have a question concerning Abstract Syntax Trees generated with Boost Spirit Library. </p>
  
  <p>I've found many informations about deleting nodes and subtrees in a Binary Search Tree, but I cannot find the same information for ASTs. I have a node in an AS-Tree, and this node is root to a subtree of a complete tree. Now I want to delete the node and all of its children. </p>
  
  <p>I don't know how to do it, and the Boost Spirit Documentation didn't help either. </p>
  
  <p>Has anyone got any tips for me?</p>
  
  <p>The Tree is generated with (Boost 1.46.1):</p>
  
  <p><code>tree_parse_info&lt;&gt; info = ast_parse(expression.c_str(), parser, skipparser);</code></p>
  
  <p>And the Expression is something like this: </p>
  
  <p><code>(variable_17 OR variable_18) AND function( variable_17) &lt;= 30 OR function( subkey_18) &lt;= 30</code></p>
  
  <p>I use</p>
  
  <p><code>tree_match&lt;iterator_t&gt;::tree_iterator tree_it = info.trees.begin();</code></p>
  
  <p>to get the beginning of the tree, and then I do check if one of the subtrees is redundant (doensn't have anything to do with the deleting itself). `Then I traverse through the tree using </p>
  
  <p><code>tree_match&lt;iterator_t&gt;::tree_iterator children_it = tree_it-&gt;children.begin()</code></p>
  
  <p>and calling the same function with its children (recursive). I can't post the complete code,but that's the most important part of it. I thought, that i can traverse to the leafnodes of a redundant subtree, and set them to null, or something like this. And then I go up the tree again, and delete all other children one after another. However, nothing has worked so far.</p>
  
  <p>An example for traversing the tree: <a href="https://stackoverflow.com/questions/18914107/c-recursion-variable">The Traversing</a>
  It's the answer.</p>
  
  <p>If I can't delete any nodes, does anyone has an idea, how to create a new tree, based on the existing one, skiping the redundant parts of it.</p>