code: private void applyFlatten() {
      if (flattenTarget == null)
        return;
  
      final List<OIdentifiable> finalResult = new ArrayList<OIdentifiable>();
      Object fieldValue;
      if (tempResult != null)
        for (OIdentifiable id : tempResult) {
          if (flattenTarget instanceof OSQLFilterItem)
            fieldValue = ((OSQLFilterItem) flattenTarget).getValue(id.getRecord(), context);
          else if (flattenTarget instanceof OSQLFunctionRuntime)
            fieldValue = ((OSQLFunctionRuntime) flattenTarget).getResult();
          else
            fieldValue = flattenTarget.toString();
  
          if (fieldValue != null)
            if (fieldValue instanceof Collection<?>) {
              for (Object o : ((Collection<?>) fieldValue)) {
                if (o instanceof OIdentifiable)
                  finalResult.add(((OIdentifiable) o).getRecord());
                else if (o instanceof List) {
                  List<OIdentifiable> list = (List<OIdentifiable>) o;
                  for (int i = 0; i < list.size(); i++)
                    finalResult.add(list.get(i).getRecord());
                }
              }
            } else
              finalResult.add((OIdentifiable) fieldValue);
        }
  
      tempResult = finalResult;
    }
docs: Extract the content of collections and/or links and put it as result