title: Trying to iterate through a graph breadth first in Python
body: <p>In my code, I am essentially trying to create an implementation of a data flow network. Although the particularities of how I am going about doing this aren't particularly important, I need some help to make the program go through the graph in a breadth first fashion.
  When I do this with my code:</p>
  
  <pre><code>def traverse(self):
      source = self._nodelist[0]
      self.sand_pile(source)
      return
  
  def sand_pile(self, start):
      for sink in start._sinks:
          //ALGORITHM FOR SENDING DATA HERE
      for s in start._sinks:
          self.sand_pile(s)
      return
  </code></pre>
  
  <p>The compiler correctly goes through the first node and its sinks breadth first, but then when it goes on to repeat the process for the sinks, it starts to go depth first. </p>
  
  <p>Another way of explaining this is the following: if the source of the graph has two or three sinks, each of which have two or three of their own sinks, the compiler will print them all out and pass the value to them successfully, but then will proceed to go depth first for the rest of the nodes until it reaches the end. Where am I going wrong in my logic? </p>
  
  <p>P.S. If I am not explaining anything well, please leave a comment so I can clarify.</p>