public boolean hasDescendant(Pattern pattern){
  Queue<BNode> nodesToProcess=new LinkedList<BNode>();
  nodesToProcess.add(this);
  while (!nodesToProcess.isEmpty()) {
    BNode currentNode=nodesToProcess.poll();
    for (    BNode descendantNode : currentNode.getOutputNodes()) {
      Matcher matcher=pattern.matcher(descendantNode.getId());
      if (matcher.matches()) {
        return true;
      }
      if (!nodesToProcess.contains(descendantNode)) {
        nodesToProcess.add(descendantNode);
      }
    }
  }
  return false;
}

public boolean hasDescendant ( Pattern pattern ) { Queue < BNode > nodesToProcess = new LinkedList < BNode > ( ) ; nodesToProcess . add ( this ) ; while ( ! nodesToProcess . isEmpty ( ) ) { BNode currentNode = nodesToProcess . poll ( ) ; for ( BNode descendantNode : currentNode . getOutputNodes ( ) ) { Matcher matcher = pattern . matcher ( descendantNode . getId ( ) ) ; if ( matcher . matches ( ) ) { return true ; } if ( ! nodesToProcess . contains ( descendantNode ) ) { nodesToProcess . add ( descendantNode ) ; } } } return false ; }
returns true if at there exists at least one descendant whose identifier matches the regular expression pattern , and false otherwise
