title: Ancestors' same-name siblings
body: <pre><code>&lt;corpus&gt;
      &lt;header id="1"&gt;
          &lt;file&gt;
              &lt;info&gt;
                  &lt;title id="A" /&gt;
              &lt;/info&gt;
          &lt;/file&gt;
      &lt;/header&gt;
      &lt;TEI&gt;
          &lt;header id="2"&gt;
              &lt;file&gt;
                   &lt;info&gt;
                       &lt;title id="B" /&gt;
                   &lt;/info&gt;
              &lt;/file&gt;
          &lt;/header&gt;
          &lt;header id="3"&gt;
              &lt;file&gt;
                   &lt;info&gt;
                       &lt;record&gt;
                            &lt;title id="C" /&gt;
                       &lt;/record&gt;
                   &lt;/info&gt;
              &lt;/file&gt;
          &lt;/header&gt;
          &lt;header id="4"&gt;
              &lt;file&gt;
              &lt;/file&gt; 
          &lt;/header&gt;
      &lt;/TEI&gt;
  &lt;/corpus&gt;
  </code></pre>
  
  <p>$list is a set of <code>&lt;title&gt;</code> nodes. </p>
  
  <p>The depth of <code>&lt;title&gt;</code> varies, but is always somewhere under a <code>&lt;header&gt;</code>. The depth of <code>&lt;header&gt;</code> varies, but its depth from root is always the same for all nodes in a given $list.</p>
  
  <p>Given a $list, I need a for-each loop that loops through headers.</p>
  
  <p>When the only node in $list is title A, I need to loop only through header 1.</p>
  
  <p>When the nodes in $list are titles B and C, I need to loop through headers 2, 3 and 4.</p>