public static @Nullable JsonSchemaObject findRelativeDefinition(@NotNull JsonSchemaObject schemaObject, @NotNull String ref) {
    if (isSelfReference(ref)) {
      return schemaObject;
    }
    if (!ref.startsWith("#/")) {
      return null;
    }
    if (Registry.is("json.schema.object.v2") && !(schemaObject instanceof JsonSchemaObjectImpl)) {
      return schemaObject.findRelativeDefinition(ref);
    }
    ref = ref.substring(2);
    final List<String> parts = split(ref);
    JsonSchemaObject current = schemaObject;
    for (int i = 0; i < parts.size(); i++) {
      if (current == null) return null;
      final String part = parts.get(i);
      if (JSON_DEFINITIONS.equals(part) || DEFS.equals(part)) {
        if (i == (parts.size() - 1)) return null;
        //noinspection AssignmentToForLoopParameter
        final String nextPart = parts.get(++i);
        current = current.getDefinitionByName(unescapeJsonPointerPart(nextPart));
        continue;
      }
      if (JSON_PROPERTIES.equals(part)) {
        if (i == (parts.size() - 1)) return null;
        //noinspection AssignmentToForLoopParameter
        current = current.getPropertyByName(unescapeJsonPointerPart(parts.get(++i)));
        continue;
      }
      if (ITEMS.equals(part)) {
        if (i == (parts.size() - 1)) {
          current = current.getItemsSchema();
        }
        else {
          //noinspection AssignmentToForLoopParameter
          Integer next = tryParseInt(parts.get(++i));
          var itemsSchemaList = current.getItemsSchemaList();
          if (itemsSchemaList != null && next != null && next < itemsSchemaList.size()) {
            current = itemsSchemaList.get(next);
          }
        }
        continue;
      }
      if (ADDITIONAL_ITEMS.equals(part)) {
        if (i == (parts.size() - 1)) {
          current = current.getAdditionalItemsSchema();
        }
        continue;
      }

      current = current.getDefinitionByName(part);
    }
    return current;
  }
public static @Nullable JsonSchemaObject findRelativeDefinition(@NotNull JsonSchemaObject schemaObject, @NotNull String ref)