title: spilling over a new node in a binary tree with the modified preoder tree traversal algorithm
body: <p>I want to implement binary tree placement in an MlM app using php, </p>
  
  <p>terms used:</p>
  
  <p>referrer, upline, downline</p>
  
  <p>A referrer will only be the upline of the first 2 reffered, additional referrals will be spilled over to the binary tree to fill any available space, from left to right</p>
  
  <p>Example: </p>
  
  <ol>
  <li>"A" refers "B and "C" and "D", </li>
  <li>"B" and "C" and placed as downlines of "A", </li>
  <li>"C" is then spilled over to the next available space.</li>
  <li><p>in this case on the left of "B" , since does not have any downline yet</p>
  
  <pre><code>  A
    /\
   /  \
  B    C
  </code></pre>
  
  <p>/
    D</p></li>
  </ol>
  
  <p>Assuming every referrer brings in only 2 people, I ama able to automatically add it into the table using modified preorder tree traversal algorithm, </p>
  
  <p>but my challenge is identifying the next available space on the table (sequentially) to add the spill over from referrer who already has 2 downlines.</p>