code: @Override
    public void printHeads(final Parse parse) {
      if (parse == null || parse.getChildCount() == 0) {
        throw new IllegalArgumentException(
            "Can't return head of null or leaf Parse.");
      }
      final LinkedList<Parse> nodes = new LinkedList<Parse>();
      nodes.add(parse);
      // This is a recursive iteration over the whole parse tree
      while (!nodes.isEmpty()) {
        final Parse currentNode = nodes.removeFirst();
        // When a node is here its '=H' annotation has already happened
        // so it '=H' has to be removed to match with the head rules
        final String type = currentNode.getType().replace(HEADMARK, "");
        if (DEBUG) {
          System.err
              .println("-> Current Node: " + type + " " + currentNode.toString());
        }
        final Parse[] children = currentNode.getChildren();
        Parse headChild = null;
        if (children.length > 0) {
          headChild = this.headRules.getHead(children, type);
        }
        // For every child, if it is the head, annotate with '=H'
        // and also add to the queue for the recursive processing
        for (final Parse child : currentNode.getChildren()) {
          if (child == headChild) {
            child.setType(child.getType() + HEADMARK);
          }
          // add child to last of LinkedList which will
          // now take as currentNode the child of this child
          nodes.addLast(child);
        }
      }
    }
docs: /*
  (non-Javadoc)
  
  @see
  eus.ixa.ixa.pipe.heads.HeadFinder#printHeads(opennlp.tools.parser.Parse)