title: BeautifulSoup counting tags without parsing deep inside them
body: <p>I thought about the following <a href="https://stackoverflow.com/questions/27673349/python-xml-parsing-algorithm-speed/27673558#27673558">while writing an answer to this question</a>.</p>
  
  <p>Suppose I have a deeply nested <code>xml</code> file like this (but much more nested and much longer):</p>
  
  <pre><code>&lt;section name="1"&gt;
      &lt;subsection name"foo"&gt;
          &lt;subsubsection name="bar"&gt;
              &lt;deeper name="hey"&gt;
                  &lt;much_deeper name"yo"&gt;
                      &lt;li&gt;Some content&lt;/li&gt;
                  &lt;/much_deeper&gt;
              &lt;/deeper&gt;
          &lt;/subsubsection&gt;
      &lt;/subsection&gt;
  &lt;/section&gt;
  &lt;section name="2"&gt;
      ... and so forth
  &lt;/section&gt;
  </code></pre>
  
  <p>The problem with <code>len(soup.find_all("section"))</code> is that while doing <code>find_all("section")</code>, BS keeps searching deep into a tag that I know won't contain any other <code>section</code> tag.</p>
  
  <p><strong>So, two questions:</strong></p>
  
  <ol>
  <li>Is there a way to make BS <strong>not</strong> search recursively into an already found tag?</li>
  <li>If the answer to 1 is yes, will it be more efficient or is it the same internal process?</li>
  </ol>