private void getFirstChildPseudo(
     JsNodeArray previousMatch, boolean previousDir, JsNodeArray matchingElms) {
   Node next;
   Node previous;
   for (int j = 0, jlen = previousMatch.size(); j < jlen; j++) {
     previous = next = previousMatch.getElement(j);
     if (previousDir) {
       while (JsUtils.truth((next = SelectorEngine.getPreviousSibling(next)))
           && next.getNodeType() != Node.ELEMENT_NODE) {}
     } else {
       while (JsUtils.truth((next = SelectorEngine.getNextSibling(next)))
           && next.getNodeType() != Node.ELEMENT_NODE) {}
     }
     if (!JsUtils.truth(next)) {
       matchingElms.addNode(previous);
     }
   }
 }
 private void getOnlyOfTypePseudo(JsNodeArray previousMatch, JsNodeArray matchingElms) {
   Node previous;
   Node next;
   Node prev;
   Node oParent = null;
   for (int o = 0, olen = previousMatch.size(); o < olen; o++) {
     prev = next = previous = previousMatch.getNode(o);
     Node prevParent = previous.getParentNode();
     if (prevParent != oParent) {
       while (JsUtils.truth(prev = SelectorEngine.getPreviousSibling(prev))
           && !JsUtils.eq(prev.getNodeName(), previous.getNodeName())) {}
       while (JsUtils.truth(next = SelectorEngine.getNextSibling(next))
           && !JsUtils.eq(next.getNodeName(), previous.getNodeName())) {}
       if (!JsUtils.truth(prev) && !JsUtils.truth(next)) {
         matchingElms.addNode(previous);
       }
       oParent = prevParent;
     }
   }
 }
 private void getOnlyChildPseudo(JsNodeArray previousMatch, JsNodeArray matchingElms) {
   Node previous;
   Node next;
   Node prev;
   Node kParent = null;
   for (int k = 0, klen = previousMatch.size(); k < klen; k++) {
     prev = next = previous = previousMatch.getNode(k);
     Node prevParent = previous.getParentNode();
     if (prevParent != kParent) {
       while (JsUtils.truth(prev = SelectorEngine.getPreviousSibling(prev))
           && prev.getNodeType() != Node.ELEMENT_NODE) {}
       while (JsUtils.truth(next = SelectorEngine.getNextSibling(next))
           && next.getNodeType() != Node.ELEMENT_NODE) {}
       if (!JsUtils.truth(prev) && !JsUtils.truth(next)) {
         matchingElms.addNode(previous);
       }
       kParent = prevParent;
     }
   }
 }
  private void getFirstOfTypePseudo(
      JsNodeArray previousMatch, boolean previousDir, JsNodeArray matchingElms) {
    Node previous;
    Node next;
    for (int n = 0, nlen = previousMatch.size(); n < nlen; n++) {
      next = previous = previousMatch.getNode(n);

      if (previousDir) {
        while (JsUtils.truth(next = SelectorEngine.getPreviousSibling(next))
            && !JsUtils.eq(next.getNodeName(), previous.getNodeName())) {}
      } else {
        while (JsUtils.truth(next = SelectorEngine.getNextSibling(next))
            && !JsUtils.eq(next.getNodeName(), previous.getNodeName())) {}
      }

      if (!JsUtils.truth(next)) {
        matchingElms.addNode(previous);
      }
    }
  }