public static TreebankNode selectMatchingLeaf(JCas jCas,Annotation annotation){
  TreebankNode leaf=null;
  for (  TreebankNode node : JCasUtil.selectCovered(jCas,TreebankNode.class,annotation)) {
    if (node.getLeaf() && node.getBegin() == annotation.getBegin() && node.getEnd() == annotation.getEnd()) {
      if (leaf == null) {
        leaf=node;
      }
 else {
        throw new IllegalArgumentException(String.format("expected one leaf matching annotation %s, found %s",annotation,Arrays.asList(leaf,node)));
      }
    }
  }
  return leaf;
}

public static TreebankNode selectMatchingLeaf ( JCas jCas , Annotation annotation ) { TreebankNode leaf = null ; for ( TreebankNode node : JCasUtil . selectCovered ( jCas , TreebankNode . class , annotation ) ) { if ( node . getLeaf ( ) && node . getBegin ( ) == annotation . getBegin ( ) && node . getEnd ( ) == annotation . getEnd ( ) ) { if ( leaf == null ) { leaf = node ; } else { throw new IllegalArgumentException ( String . format ( "expected one leaf matching annotation %s, found %s" , annotation , Arrays . asList ( leaf , node ) ) ) ; } } } return leaf ; }
selects a single treebanknode leaf that has the same span as the given annotation .
