docs: @SuppressWarnings("checkstyle:npathcomplexity")
      public static JsonValue findValueWithPattern(NavigableJsonInputAdapter input,
                                                   JsonSchemaNode schemaNode, JsonPattern expectedPattern,
                                                   JsonPathCursor attributePath) throws IOException {
          for (int i = 0; i < expectedPattern.depth(); i++) {
              if (attributePath.getNext() == null) {
                  return null;
              }
              if (schemaNode.isTerminal()) {
                  return null;
              }
              int expectedOrderIndex = expectedPattern.get(i);
              JsonSchemaStructNode structDescription = (JsonSchemaStructNode) schemaNode;
              if (structDescription.getChildCount() <= expectedOrderIndex) {
                  return null;
              }
              JsonSchemaNameValue nameValue = structDescription.getChild(expectedOrderIndex);
              if (structMatches(input, nameValue, expectedOrderIndex, attributePath)) {
                  schemaNode = nameValue.getValue();
              } else {
                  return null;
              }
          }
          if (attributePath.getNext() == null) {
              if (schemaNode.isTerminal()) {
                  // at this point we are sure we found the value by pattern. So we have to be able to extract JsonValue.
                  // Otherwise, let the exceptions propagate
                  try {
                      JsonReducedValueParser valueParser = new JsonReducedValueParser();
                      int valuePos = ((JsonSchemaTerminalNode) schemaNode).getValueStartLocation();
                      return input.parseValue(valueParser, valuePos);
                  } catch (ParseException parseException) {
                      throw new HazelcastException(parseException);
                  }
              } else {
                  return NonTerminalJsonValue.INSTANCE;
              }
          }
          return null;
      }