private static Object dg(int a){ Map map = new HashMap(); map.put("id",a); if(a<5){ map.put("children",dg(++a)); } return map; }