void (List<ServiceViewItem> children, ServiceNode child, ServiceViewContributor<?> contributor) { if (!children.isEmpty() && contributor instanceof Comparator) { @SuppressWarnings("unchecked") Comparator<Object> comparator = (Comparator<Object>)contributor; for (int i = 0; i < children.size(); i++) { ServiceViewItem anchor = children.get(i); if (anchor instanceof ServiceNode) { if (comparator.compare(child.getService(), ((ServiceNode)anchor).getService()) < 0) { children.add(i, child); return; } } } } children.add(child); }