title: Algorithm for a tree comment system with unlimited nesting?
body: <p>I need to do a tree comment system for a highload Zend framework-based web-service with unlimited nesting, also this system must be very fast.</p>
  
  <p>Comments must be sent for Zend_View in simple array such as bellow. In Zend_View whole comments will be displayed via foreach(). Structure will be shown with CSS classes.</p>
  
  <pre><code>array(
     '0' =&gt; 'comment1 (here must be a a much of data)',
     '1' =&gt; 'comment for comment1',
     '2' =&gt; 'comment2',
     '3' =&gt; 'comment3',
     '4' =&gt; 'comment for comment3',
     '5' =&gt; 'comment of comment ^_^ '
  );
  </code></pre>
  
  <p>Now, I can receive all comments required page from model, which sorted by date. Their structure specified below. </p>
  
  <p>id | page_id | user | parent | date | text &amp; etc</p>
  
  <p><strong>id</strong> - AI primary key</p>
  
  <p><strong>page_id</strong> - TINY int</p>
  
  <p><strong>user</strong> - int</p>
  
  <p><strong>parent</strong> - TINY int</p>
  
  <p><strong>data</strong> - timestamp</p>