title: Implementing Consolidate in Fibonacci heap
body: <p>The pseudocode from <em><a href="http://mitpress.mit.edu/books/introduction-algorithms" rel="nofollow">Introduction to Algorithms</a></em> states:</p>
  
  <pre><code>for each node w in the root list of H
    link trees of the same degree
  </code></pre>
  
  <p>But how to efficiently implement the <em>for each root node</em> part? Original roots are linked to other roots of the same degree throughout the process of consolidation, which makes it difficult to just pass through the circular list of root nodes. How can I decide whether I have checked every root node or not? </p>