void (final TreeNode node, final List<Object> selection) { final List<?> currentlySelected = myFlatView.getSelectedObjects(); final List<?> targetSelection = !currentlySelected.isEmpty() ? currentlySelected : selection; myTreeView.getTreeViewModel().setRoot(node); if ((targetSelection != null) && (!targetSelection.isEmpty())) { final List items = myFlatView.getItems(); for (Object selElement : targetSelection) { if (items.contains(selElement)) { final int idx = items.indexOf(selElement); setSelectionInterval(idx, idx); } } } }