title: Print every leaf path of a tree without recursive
body: <p>How do I print every leaf path of a tree without using recursion.</p>
  
  <p>It is a tree, <em>NOT</em> a binary tree </p>
  
  <pre><code>struct node {
      int data
      std::vector&lt;node*&gt; children;
  }
  </code></pre>
  
  <p>Print all the path from root to leaf, i.e. the following is the tree</p>
  
  <ul>
  <li>r:is the root node</li>
  <li>d, m, n are r's children</li>
  <li>x,y,z are d's children</li>
  <li>there is no child for m</li>
  <li>o, p are n's children</li>
  </ul>
  
  <pre>
  -------------root
  ------d         m          n
  ---x  y  z              o  p
  </pre>
  
  <p>The result should be:</p>
  
  <pre>
  root-d-x
  root-d-y
  root-d-z
  root-m
  root-n-o
  root-n-p
  </pre>
  
  <p>I tried to use non-recursive way but failed.</p>