private void sortPropertiesAndCreateGroups(List<Property> rootProperties) {
    if (!mySorted && !myShowGroups) return;

    rootProperties.sort((o1, o2) -> {
      if (o1.getParent() != null || o2.getParent() != null) {
        if (o1.getParent() == o2) return -1;
        if (o2.getParent() == o1) return 1;
        return 0;
      }

      if (myShowGroups) {
        int result = getGroupComparator().compare(o1.getGroup(), o2.getGroup());
        if (result != 0) return result;
      }
      return mySorted ? getPropertyComparator().compare(o1, o2) : 0;
    });

    if (myShowGroups) {
      for (int i = 0; i < rootProperties.size() - 1; i++) {
        Property prev = i == 0 ? null : rootProperties.get(i - 1);
        Property each = rootProperties.get(i);

        String eachGroup = each.getGroup();
        String prevGroup = prev == null ? null : prev.getGroup();

        if (prevGroup != null || eachGroup != null) {
          if (!StringUtil.equalsIgnoreCase(eachGroup, prevGroup)) {
            rootProperties.add(i, new GroupProperty(each.getGroup()));
            i++;
          }
        }
      }
    }
  }
private void sortPropertiesAndCreateGroups(List<Property> rootProperties)