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