public Page getPage(TreePath path) {
        Object[] way = path.getPath();
        PageInfo page = (PageInfo)way[0];
        for (int i = 1; i < path.getPathCount(); i++) {
            boolean found = false;
            for (PageInfo p : page.getSubPages()) {
                if (way[i] == p) {
                    page = p;
                    found = true;
                    break;
                }
            }

            if (!found) {
                page = null;
                break;
            }
        }

        return (Page)page;
    }