ServiceViewItem (Deque<String> path, List<? extends ServiceViewItem> roots) { String id = path.removeFirst(); for (ServiceViewItem root : roots) { if (id.equals(root.getViewDescriptor().getId())) { return path.isEmpty() ? root : findItemById(path, root.getChildren()); } } return null; }