title: Sitecore query: Get first ancestor that matches condition
body: <p>I have the following sitecore query:</p>
  
  <pre><code>./ancestor::*[@@templatename='Template 1' or @@templatename='Template 2']//*[@@templatename='Target']/*
  </code></pre>
  
  <p>which works, but if the the context item have both Template 1 and 2 as an ancestor, i get double results. So i basically want to stop at the first ancestor who matches the template. I've tried getting the first match like this:</p>
  
  <pre><code>./ancestor::*[@@templatename='Template 1' or @@templatename='Template 2'][1]//*[@@templatename='Target']/*
  </code></pre>
  
  <p>But that results in an error. Any help is appreciated</p>