private static @Nullable <E extends ArrangementEntry> Collection<E> arrangeByRule(@NotNull List<? super E> arranged,
                                                                                    @NotNull MultiMap<ArrangementMatchRule, E> elementsByRule,
                                                                                    @NotNull ArrangementMatchRule rule) {
    if (elementsByRule.containsKey(rule)) {
      List<E> arrangedEntries = (List<E>)elementsByRule.remove(rule);
      assert arrangedEntries != null;

      ArrangementSettingsToken order = rule.getOrderType();
      if (order instanceof CustomArrangementOrderToken) {
        arrangedEntries.sort(((CustomArrangementOrderToken)order).getEntryComparator());
      }
      else if (rule.getOrderType().equals(StdArrangementTokens.Order.BY_NAME)) {
        sortByName(arrangedEntries);
      }

      arranged.addAll(arrangedEntries);
      return arrangedEntries;
    }
    return null;
  }
private static @Nullable <E extends ArrangementEntry> Collection<E> arrangeByRule(@NotNull List<? super E> arranged,
                                                                                    @NotNull MultiMap<ArrangementMatchRule, E> elementsByRule,
                                                                                    @NotNull ArrangementMatchRule rule)