title: extract specific element from nested elements using lxml html
body: <p>Hi all I am having some problems that I think can be attributed to xpath problems. I am using the html module from the lxml package to try and get at some data. I am providing the most simplified situation below, but keep in mind the html I am working with is much uglier.</p>
  
  <pre><code>&lt;table&gt;
      &lt;tr&gt;
      &lt;td&gt;
          &lt;table&gt;
              &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;
                  &lt;table&gt;
                      &lt;tr&gt;&lt;td&gt;&lt;u&gt;&lt;b&gt;Header1&lt;/b&gt;&lt;/u&gt;&lt;/td&gt;&lt;/tr&gt; 
                      &lt;tr&gt;&lt;td&gt;Data&lt;/td&gt;&lt;/tr&gt;
                  &lt;/table&gt;
              &lt;/td&gt;&lt;/tr&gt;
          &lt;/table&gt;
       &lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>What I really want is the deeply nested table, because it has the header text "Header1".
  I am trying like so:</p>
  
  <pre><code>from lxml import html
  page = '...'
  tree = html.fromstring(page)
  print tree.xpath('//table[//*[contains(text(), "Header1")]]')
  </code></pre>
  
  <p>but that gives me all of the table elements. I just want the one table that contains this text. I understand what is going on but am having a hard time figuring out how to do this besides breaking out some nasty regex. 
  Any thoughts? </p>