void (List<ServiceViewItem> children, ServiceGroupNode child) { if (!children.isEmpty()) { for (int i = 0; i < children.size(); i++) { ServiceViewItem anchor = children.get(i); if (anchor instanceof ServiceNode) { children.add(i, child); return; } else if (anchor instanceof ServiceGroupNode) { if (compareGroups(child, (ServiceGroupNode)anchor) < 0) { children.add(i, child); return; } } } } children.add(child); }