private Map<String, Object> buildSubcategory(SubCategory category, String code, String name) {
   final Map<String, Object> categoryNode = new HashMap<String, Object>();
   categoryNode.put(METADATA, buildMetadataMap(category, code, name));
   categoryNode.put(DATA, category.getName());
   if (category.getSubCategories() != null && !category.getSubCategories().isEmpty()) {
     final List<Map<String, Object>> subCategoryNodes = new ArrayList<Map<String, Object>>();
     for (SubCategory subCategory : category.getSubCategories()) {
       final String subCategoryNodeCode =
           code + CategoryBranch.CODE_SEPARATOR + category.getCode();
       final String subCategoryNodeName =
           name + CategoryBranch.NAME_SEPARATOR + category.getName();
       final Map<String, Object> subCategoryNode =
           buildSubcategory(subCategory, subCategoryNodeCode, subCategoryNodeName);
       subCategoryNodes.add(subCategoryNode);
     }
     categoryNode.put(CHILDREN, subCategoryNodes);
   }
   return categoryNode;
 }
 private Map<String, Object> buildMetadataMap(SubCategory c, String code, String name) {
   final Map<String, Object> map = new HashMap<String, Object>();
   map.put(CODE, code != null ? code + CategoryBranch.CODE_SEPARATOR + c.getCode() : c.getCode());
   map.put(NAME, name != null ? name + CategoryBranch.NAME_SEPARATOR + c.getName() : c.getName());
   return map;
 }