title: xpath - How do I get a node that may or may not contain a parent node
body: <p>I'm currently building a Python script that will pull all Oscar nominated Best Picture movies from the <a href="https://en.wikipedia.org/wiki/Academy_Award_for_Best_Picture" rel="nofollow noreferrer">wikipedia page</a>. I've made two different lists for the winners and the nominees.</p>
  <pre><code>from lxml import etree
  import requests
  r = requests.get('https://en.wikipedia.org/wiki/Academy_Award_for_Best_Picture')
  doc = etree.fromstring(r.text)
  winners = doc.xpath('//tr[@style=&quot;background:#FAEB86&quot;]/td/i/b/a')
  nominees = doc.xpath('//tr/td/i/a')
  </code></pre>
  <p>As you can see, I'm focusing on the last node as that has both the name of the movie. I am able to get all the movies on for each list, but I want to put them in one list together using xpath. I know I could merge the two lists together, but the movies have to be in the order they appear on the wiki page.</p>
  <p>The main problem comes from the nodes with @style and /b, which both come before /a. I tried putting them together in a single line</p>
  <pre><code>winners = doc.xpath('//tr[@style=&quot;background:#FAEB86&quot; or not(@style=&quot;background:#FAEB86&quot;)]/td/i[b or not(b)]/a')
  </code></pre>
  <p>but I only get the most recent winner (Moonlight) at the beginning of the list, and the rest of the list is just the nominated movies.</p>
  <p>Is it possible to put my two list together in a single statement, or will I have to write a work around that puts the movies in the correct oder?</p>