private static boolean moveToEnd(ImmutableActionChangeRange @NotNull [] ranges, @NotNull Set<Integer> rangesToMove) {
    for (int pass = 0; pass < rangesToMove.size(); pass++) {
      int destinationIndex = ranges.length - pass - 1;
      int currentIndex = destinationIndex;
      for (; currentIndex >= 0; currentIndex--) {
        if (rangesToMove.contains(ranges[currentIndex].getId())) {
          break;
        }
      }
      if (currentIndex < 0) {
        throw new IllegalArgumentException("Array doesn't contain specified ranges");
      }
      for (; currentIndex < destinationIndex; currentIndex++) {
        if (!swap(ranges, currentIndex)) {
          return false;
        }
      }
    }
    return true;
  }
private static boolean moveToEnd(ImmutableActionChangeRange @NotNull [] ranges, @NotNull Set<Integer> rangesToMove)