code: @SuppressWarnings("checkstyle:npathcomplexity")
      public static JsonPattern createPattern(NavigableJsonInputAdapter input, JsonSchemaNode schemaNode, JsonPathCursor path) {
          if (schemaNode.isTerminal()) {
              return null;
          }
          JsonPattern pattern = new JsonPattern();
          while (path.getNext() != null) {
              if (schemaNode.isTerminal()) {
                  return null;
              }
              int suggestedIndexInPath;
              int numberOfChildren = ((JsonSchemaStructNode) schemaNode).getChildCount();
              if (path.isArray()) {
                  if (path.isAny()) {
                      pattern.addAny();
                      return pattern;
                  }
                  suggestedIndexInPath = path.getArrayIndex();
              } else {
                  for (suggestedIndexInPath = 0; suggestedIndexInPath < numberOfChildren; suggestedIndexInPath++) {
                      JsonSchemaNameValue nameValue = ((JsonSchemaStructNode) schemaNode)
                              .getChild(suggestedIndexInPath);
                      int nameAddress = nameValue.getNameStart();
                      if (nameAddress < 0) {
                          return null;
                      }
                      input.position(nameAddress);
                      if (input.isAttributeName(path)) {
                          break;
                      }
                  }
              }
              if (isValidIndex(suggestedIndexInPath, (JsonSchemaStructNode) schemaNode, path.isArray())) {
                  schemaNode = ((JsonSchemaStructNode) schemaNode).getChild(suggestedIndexInPath).getValue();
                  pattern.add(suggestedIndexInPath);
              } else {
                  return null;
              }
          }
          return pattern;
      }
docs: Creates a {@link JsonPattern} for given query path. If the path
  matches a terminal value in the schema, then the schema is
  returned. Otherwise this method returns null. If given path
  has "any", pattern is created only upto that part. The rest is
  omitted.
  
  @param input         a buffer containing the queried object.
  @param schemaNode the description of the given object
  @param path          query path
  @return              a pattern object matching the path or null
  when path does not match a terminal value
  @throws IOException