private static <T, G> ServiceNode addGroupNode(ServiceViewGroupingContributor<T, G> groupingContributor,
                                                 T service,
                                                 Object value,
                                                 ServiceViewItem parent,
                                                 Project project,
                                                 List<ServiceViewItem> children) {
    List<G> groups = groupingContributor.getGroups(service);
    if (groups.isEmpty()) return null;

    List<ServiceViewItem> currentChildren = children;
    ServiceViewItem groupParent = parent;
    for (G group : groups) {
      boolean found = false;
      for (ServiceViewItem child : currentChildren) {
        if (child.getValue().equals(group)) {
          groupParent = child;
          currentChildren = groupParent.getChildren();
          found = true;
          break;
        }
      }
      if (!found) {
        ServiceGroupNode groupNode =
          new ServiceGroupNode(group, groupParent, groupingContributor, groupingContributor.getGroupDescriptor(group));
        addGroupOrdered(currentChildren, groupNode);
        groupParent = groupNode;
        currentChildren = groupParent.getChildren();
      }
    }
    ServiceNode
      serviceNode = new ServiceNode(value, groupParent, groupingContributor, groupingContributor.getServiceDescriptor(project, service),
                                    project, service instanceof ServiceViewContributor ? (ServiceViewContributor<?>)service : null);
    addServiceOrdered(currentChildren, serviceNode, groupingContributor);
    return serviceNode;
  }
private static <T, G> ServiceNode addGroupNode(ServiceViewGroupingContributor<T, G> groupingContributor,
                                                 T service,
                                                 Object value,
                                                 ServiceViewItem parent,
                                                 Project project,
                                                 List<ServiceViewItem> children)