TreeState (@NotNull JTree tree, boolean persistExpand, boolean persistSelect) { List<TreePath> expanded = persistExpand ? TreeUtil.collectExpandedPaths(tree) : Collections.emptyList(); List<TreePath> selected = persistSelect ? TreeUtil.collectSelectedPaths(tree) : Collections.emptyList(); return createOn(tree, expanded, selected); }