@SuppressWarnings("unchecked")
 private <T> void convertToJson(Iterable<T> items, JSONArray results) throws JSONException {
   for (T resultObject : items) {
     if (resultObject instanceof Element) {
       results.put(GraphSONUtility.jsonFromElement((Element) resultObject, null, graphsonMode));
     } else if (resultObject instanceof List) {
       convertToJson((Iterable<T>) resultObject, results);
     }
   }
 }
  public <T extends Element> JsonObject serializeElement(T element) throws IOException {
    JSONObject elementJson;
    try {
      elementJson = GraphSONUtility.jsonFromElement(element, null, graphsonMode);
    } catch (JSONException e) {
      throw new IOException(e);
    } finally {
    }

    return new JsonObject(elementJson.toString());
  }