* value.
*
* @param hf The headfinding algorithm to use
*/
public void percolateHeads(HeadFinder hf) {
Label cwt = label();
if (isLeaf()) {
if (cwt instanceof HasWord) {
HasWord w = (HasWord) cwt;
if (w.word() == null) {
w.setWord(cwt.value());
}
}
} else {
Tree[] kids = children();
for (int i = 0; i < kids.length; i++) {
kids[i].percolateHeads(hf);
}
Tree head = hf.determineHead(this);
if (head != null) {
Label headCwt = head.label();
String headTag = null;
if (headCwt instanceof HasTag) {
headTag = ((HasTag) headCwt).tag();
}
if (headTag == null && head.isLeaf()) {
// below us is a leaf
headTag = cwt.value();
}
String headWord = null;
if (headCwt instanceof HasWord) {
headWord = ((HasWord) headCwt).word();
}
if (headWord == null && head.isLeaf()) {
// below us is a leaf
// this might be useful despite case for leaf above in
// case the leaf label type doesn't support word()
headWord = headCwt.value();
}
if (cwt instanceof HasWord) {
((HasWord) cwt).setWord(headWord);
}
if (cwt instanceof HasTag) {