title: Get an element and its parent ONLY, using BeautifulSoup in Python
body: <p>I would like to use the <code>find_all</code> function of <a href="http://www.crummy.com/software/BeautifulSoup/bs4/doc/" rel="nofollow">BeautifulSoup</a> to retrieve all <code>&lt;li&gt;</code> tag but also their parent.</p>
  
  <pre><code>&lt;div name="div1"&gt;
      &lt;li&gt;Test 1&lt;/li&gt;
      &lt;li&gt;Test 2&lt;/li&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>If I try with this code:</p>
  
  <pre><code>tags = soup.find_all("li")
  print tags[0].parent
  </code></pre>
  
  <p>This will print:</p>
  
  <pre><code>&lt;div name="div1"&gt;
      &lt;li&gt;Test 1&lt;/li&gt;
      &lt;li&gt;Test 2&lt;/li&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Because the parent contains the two <code>&lt;li&gt;</code> tags.</p>
  
  <p>What I expect is:</p>
  
  <pre><code>&lt;div name="div1"&gt;
      &lt;li&gt;Test 1&lt;/li&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>How to solve this issue please?</p>