private static int lastIndexOf(Object o, Object @NotNull [] elements, int index) {
    if (o == null) {
      for (int i = index; i >= 0; i--) {
        if (elements[i] == null) {
          return i;
        }
      }
    }
    else {
      for (int i = index; i >= 0; i--) {
        if (o.equals(elements[i])) {
          return i;
        }
      }
    }
    return -1;
  }
private static int lastIndexOf(Object o, Object @NotNull [] elements, int index)