private String buildImpactJSONTree(ServiceBean[] serviceBeans) {
    StringBuilder builder = new StringBuilder();
    builder.append(
        "{ "
            + buildJSONforNoEdgeAttributes(UUID.randomUUID().toString(), "Services", null)
            + appendChildrenJSON());
    int count = 0;
    Map<String, Map<String, ServiceBean>> serviceVersionHierarchy =
        buildServiceVersionHierarchy(serviceBeans);
    for (Map.Entry<String, Map<String, ServiceBean>> e : serviceVersionHierarchy.entrySet()) {
      Map<String, ServiceBean> versionMap = e.getValue();
      count++;
      int countInner = 0;
      for (Map.Entry<String, ServiceBean> versionEntry : versionMap.entrySet()) {
        countInner++;
        String key = versionEntry.getKey();
        ServiceBean serviceBean = versionEntry.getValue();
        if (countInner == 1) {
          builder.append(
              "{"
                  + buildJSONforNoEdgeAttributes(
                      serviceBean.getId(),
                      serviceBean.getQName(),
                      getResourceURL(serviceBean.getPath()))
                  + appendChildrenJSON()
                  + "\n");
        }
        String uuid = UUIDGenerator.generateUUID();
        String servicePath;
        if (key.equals("SNAPSHOT")) {
          servicePath = serviceBean.getPath();
        } else {
          String name = serviceBean.getQName();
          name = name.substring(0, name.lastIndexOf("-") - 1).trim();
          servicePath = serviceBean.getPath() + "/" + key + "/" + name;
        }
        builder.append(
            "{"
                + buildOpenJSONWithEdges(
                    uuid, key, serviceBean.getId(), "", getResourceURL(servicePath))
                + appendChildrenJSON()
                + "\n");
        PolicyBean[] policyBeans = serviceBean.getPolicyBeans();
        WSDLBean[] wsdlBeans = serviceBean.getWsdlBeans();
        SchemaBean[] schemaBeans = serviceBean.getSchemaBeans();
        if (policyBeans != null) {
          for (int j = 0; j < policyBeans.length; j++) {
            if (policyBeans[j] != null) {
              builder.append(
                  "{"
                      + buildJSONWithEdgeNoChildren(
                          policyBeans[j].getId(),
                          policyBeans[j].getQName(),
                          uuid,
                          "Policy",
                          getResourceURL(policyBeans[j].getPath()))
                      + "} \n");
              if (j != (policyBeans.length - 1)) builder.append(",");
              builder.append("\n");
            }
          }
          builder.append(buildCloseJSONForNameandChildren());
          if (wsdlBeans != null || schemaBeans != null) {
            builder.append(", \n");
          }
        }
        if (wsdlBeans != null) {
          for (int j = 0; j < wsdlBeans.length; j++) {
            if (wsdlBeans[j] != null) {
              builder.append(
                  "{"
                      + buildOpenJSONWithEdges(
                          wsdlBeans[j].getId(),
                          wsdlBeans[j].getQName(),
                          uuid,
                          "WSDL",
                          getResourceURL(wsdlBeans[j].getPath()))
                      + appendChildrenJSON()
                      + " \n");
              SchemaBean[] attachedSchemas = wsdlBeans[j].getAttachedSchemas();
              if (attachedSchemas != null) {
                for (int k = 0; k < attachedSchemas.length; k++) {
                  if (attachedSchemas[k] != null) {
                    builder.append(
                        "{"
                            + buildJSONWithEdgeNoChildren(
                                attachedSchemas[k].getId(),
                                attachedSchemas[k].getQName(),
                                wsdlBeans[j].getId(),
                                "Schema",
                                getResourceURL(attachedSchemas[k].getPath()))
                            + "} \n");
                    if (j != (attachedSchemas.length - 1)) {
                      builder.append(",");
                    }
                    builder.append("\n");
                  }
                }
              }
              builder.append("] \n");
              builder.append("} \n");
              if (j != (wsdlBeans.length - 1)) builder.append(",");
              builder.append("\n");
            }
          }
          if (schemaBeans != null) {
            builder.append(", \n");
          }
        }
        if (schemaBeans != null) {
          for (int j = 0; j < schemaBeans.length; j++) {
            if (schemaBeans[j] != null) {
              builder.append(
                  "{"
                      + buildJSONWithEdgeNoChildren(
                          schemaBeans[j].getId(),
                          schemaBeans[j].getQName(),
                          uuid,
                          "Schema",
                          getResourceURL(schemaBeans[j].getPath()))
                      + "} \n");
              if (j != (schemaBeans.length - 1)) builder.append(",");
              builder.append("\n");
            }
          }
        }
        builder.append("] \n");
        builder.append("} \n");
        if (countInner != (versionMap.size())) {
          builder.append(", ");
        }
        builder.append("\n");
      }
      builder.append("] \n");
      builder.append("} \n");
      if (count != (serviceVersionHierarchy.size())) {
        builder.append(", ");
      }
      builder.append("\n");
    }
    builder.append("] \n");
    builder.append("} \n");

    return builder.toString();
  }