示例#1
0
 protected void cacheDescendantsHelper(Node n) {
   for (Node child : n.getChildNodes()) {
     if (descendants.contains(child)) {
       continue;
     }
     descendants.add(child);
     cacheDescendantsHelper(child);
   }
 }
示例#2
0
 protected boolean isAncestorHelper(List<Node> children, Node node, Set<Node> seenNodes) {
   for (Node n : children) {
     if (seenNodes.contains(n)) {
       continue;
     }
     seenNodes.add(n);
     if (n.equals(node)) {
       return true;
     }
     if (isAncestorHelper(n.getChildNodes(), node, seenNodes)) {
       return true;
     }
   }
   return false;
 }