Url () { RepositoryTreeNode node = myRepositoryBrowser.getSelectedNode(); // find the most top parent of type RepositoryTreeNode while (node != null && node.getParent() instanceof RepositoryTreeNode) { node = (RepositoryTreeNode)node.getParent(); } return node != null ? node.getURL() : null; }