code: @Override
      public JsonNode visit(JmesPathFlatten flatten, JsonNode input) throws InvalidTypeException {
          JsonNode flattenResult = flatten.getFlattenExpr().accept(this, input);
          if (flattenResult.isArray()) {
              Iterator<JsonNode> elements = flattenResult.elements();
              ArrayNode flattenedArray = ObjectMapperSingleton.getObjectMapper().createArrayNode();
              while (elements.hasNext()) {
                  JsonNode element = elements.next();
                  if (element != null) {
                      if (element.isArray()) {
                          Iterator<JsonNode> inner = element.iterator();
                          while (inner.hasNext()) {
                              JsonNode innerElement = inner.next();
                              if (innerElement != null) {
                                  flattenedArray.add(innerElement);
                              }
                          }
                      } else {
                          flattenedArray.add(element);
                      }
                  }
              }
              return flattenedArray;
          }
  
          return NullNode.getInstance();
      }
docs: Flattens out the elements of the given expression into a
  single list. It's evaluated as follows.
  Create an empty result list.
  Iterate over the elements of the current result.
  If the current element is not a list, add to the end of
  the result list.
  If the current element is a list, add each element of the
  current element to the end of the result list.
  The result list is now the new current result.
  
  @param flatten JmesPath flatten type
  @param input   Input json node against which evaluation is done
  @return Result of the flatten evaluation
  @throws InvalidTypeException