int height1(const Tree& T) {
int h = 0;
PositionIterator nodes = T.positions();
while (nodes.hasNext()) {
Position v = nodes.next();
if (T.isExternal(v)) // v is a leaf?
h = max(h, depth(T, v)); // max depth among leaves
}
return h;
}