void (final @NotNull Tree tree, JComponent mainComponent, CheckboxTreeBase.CheckboxTreeCellRendererBase cellRenderer) { removeTreeListeners(mainComponent); tree.setCellRenderer(cellRenderer); tree.setRootVisible(false); tree.setShowsRootHandles(true); TreeUtil.installActions(tree); KeyListener keyListener = setupKeyListener(tree, mainComponent); ClickListener clickListener = setupMouseListener(tree, mainComponent, cellRenderer); ComponentUtil.putClientProperty(mainComponent, TREE_LISTENERS_REMOVER, () -> { mainComponent.removeKeyListener(keyListener); clickListener.uninstall(mainComponent); }); }