public boolean isLeaf(Object node) {
        if (node instanceof Page) {
            Page p = (Page)node;
            return (p.children.size() + p.names.size()) == 0;
        } else if (node instanceof Name) {
            return true;
        } else {
            throw new NotImplementedException();
        }
    }