BlockTreeNode (TextRange range) { if (myTreeModel == null || !myBlockStructurePanel.isVisible()) { return null; } DefaultMutableTreeNode root = getRoot(); if (root == null) return null; BlockTreeNode node = (BlockTreeNode)root.getUserObject(); main_loop: while (true) { if (node.getBlock().getTextRange().equals(range)) { return node; } for (BlockTreeNode child : node.getChildren()) { if (child.getBlock().getTextRange().contains(range)) { node = child; continue main_loop; } } return node; } }