title: method resolution order MRO
body: <p>Why after searching B, it does not go deeper to search Y OR z but go to search A?  </p>
  
  <p>Y is the parent of A, if should search A first, but Y is the parent of B so it should search Y first, why this does not throw a MRO error?</p>
  
  <p>Can someone explain how this lookup works?</p>
  
  <pre><code>class X(object):pass
  class Y(object): pass
  class Z(object): pass
  class A(X,Y): pass
  class B(Y,Z):pass
  class M(B,A,Z):pass
  print M.__mro__
  </code></pre>
  
  <p>gives</p>
  
  <pre><code>(&lt;class '__main__.M'&gt;, &lt;class '__main__.B'&gt;, &lt;class '__main__.A'&gt;, &lt;class '__main__.X'&gt;, &lt;class '__main__.Y'&gt;, &lt;class '__main__.Z'&gt;, &lt;type 'object'&gt;)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/G2P2i.png" rel="noreferrer"><img src="https://i.stack.imgur.com/G2P2i.png" alt="enter image description here"></a></p>