title: XPath to find nodes having 2 leaf children
body: <p>I have an XML like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Math mode="inline" tex="\tilde{p}_{d}\leq\tilde{p}_{d+1}" text="(tilde@(p)) _ d less= (tilde@(p)) _ (d + 1)"&gt;
      &lt;RMath&gt;
          &lt;RApp&gt;
              &lt;RTok meaning="less-than-or-equals" name="leq" role="RELOP"&gt;?&lt;/RTok&gt;
              &lt;RApp&gt;
                  &lt;RTok role="SUBSCRIPTOP" scriptpos="post2"/&gt;
                  &lt;RApp&gt;
                      &lt;RTok name="tilde" role="OVERACCENT" stretchy="false"&gt;~&lt;/RTok&gt;
                      &lt;RTok role="UNKNOWN" font="italic"&gt;p&lt;/RTok&gt;
                  &lt;/RApp&gt;
                  &lt;RTok role="UNKNOWN" font="italic"&gt;d&lt;/RTok&gt;
              &lt;/RApp&gt;
              &lt;RApp&gt;
                  &lt;RTok role="SUBSCRIPTOP" scriptpos="post2"/&gt;
                  &lt;RApp&gt;
                      &lt;RTok name="tilde" role="OVERACCENT" stretchy="false"&gt;~&lt;/RTok&gt;
                      &lt;RTok role="UNKNOWN" font="italic"&gt;p&lt;/RTok&gt;
                  &lt;/RApp&gt;
                  &lt;RApp&gt;
                      &lt;RTok meaning="plus" role="ADDOP"&gt;+&lt;/RTok&gt;
                      &lt;RTok role="UNKNOWN" font="italic"&gt;d&lt;/RTok&gt;
                      &lt;RTok meaning="1" role="NUMBER"&gt;1&lt;/RTok&gt;
                  &lt;/RApp&gt;
              &lt;/RApp&gt;
          &lt;/RApp&gt;
      &lt;/RMath&gt;
  &lt;/Math&gt;
  </code></pre>
  
  <p>I want to use XPath to extract the nodes which have 2 children where the 2 children are leaf nodes such as: </p>
  
  <pre><code>&lt;RApp&gt;
        &lt;RTok name="tilde" role="OVERACCENT" stretchy="false"&gt;~&lt;/RTok&gt;
        &lt;RTok role="UNKNOWN" font="italic"&gt;p&lt;/RTok&gt;
  &lt;/RApp&gt;
  </code></pre>
  
  <p>I can not think of the appropriate predicates for this extraction.</p>
  
  <p>I know that <code>.//*[not(child::*)]</code> find all the leaf nodes.</p>
  
  <p>and <code>//*[not(child::*) and (ancestor-or-self::XMApp)]</code> will find all leaf nodes with ancestor tag <code>RApp</code>.</p>
  
  <p>I do not want the node (RApp) but just want its children? i.e. any 2 leaf sibling that does not have any other sibling.</p>
  
  <p>Any help would be much appreciated. </p>