public static int diskSpace (Tree T, Position v) {
int s = size(v); // start with the size of the node itself
Iterator children = T.children(v);
while (children.hasNext()) {
// add the recursively computed space used by the children of v
s += diskSpace(T, (Position) children.next());
}
if (T.isInternal(v)) {
// print name and disk space used
System.out.print(name(v) + ": " + s);
}
return s;
}