title: Traverse JSON data structure into tree in java
body: <p>I need to build a tree from JSON. The JSON structure reads, for every restProjectLevel : restProjectLevels I have an id = level were on. A sequenceNr = root or child. For every restProject : restProjects I have an id = projectId and a projectIdHook = the projectId that's attached.</p>
  
  <p>I think the JSON data will explan it best.</p>
  
  <pre><code>{
      "id": 3,
      "description": "New Project Plan",
      "restProjectLevels": [
          {
              "id": 19,
              "sequenceNr": 0,
              "restProjects": [
                  {
                      "id": 28,
                      "projectName": "Project A",
                      "description": "",
                      "projectLevelId": 19,
                      "projectIdHook": 0,
                      "restProjectProcesses": []
                  },
                  {
                      "id": 29,
                      "projectName": "Project B",
                      "description": "",
                      "projectLevelId": 19,
                      "projectIdHook": 0,
                      "restProjectProcesses": []
                  },
                  {
                      "id": 30,
                      "projectName": "Project C",
                      "description": "",
                      "projectLevelId": 19,
                      "projectIdHook": 0,
                      "restProjectProcesses": []
                  },
                  {
                      "id": 41,
                      "projectName": "New",
                      "description": "",
                      "projectLevelId": 19,
                      "projectIdHook": 0,
                      "restProjectProcesses": []
                  }
              ]
          },
          {
              "id": 20,
              "sequenceNr": 1,
              "restProjects": [
                  {
                      "id": 31,
                      "projectName": "Project A.1",
                      "description": "",
                      "projectLevelId": 20,
                      "projectIdHook": 28,
                      "restProjectProcesses": []
                  },
                  {
                      "id": 33,
                      "projectName": "Project B.1",
                      "description": "",
                      "projectLevelId": 20,
                      "projectIdHook": 29,
                      "restProjectProcesses": []
                  },
                  {
                      "id": 35,
                      "projectName": "Project C.1",
                      "description": "",
                      "projectLevelId": 20,
                      "projectIdHook": 30,
                      "restProjectProcesses": []
                  }
              ]
          },
          {
              "id": 21,
              "sequenceNr": 2,
              "restProjects": [
                  {
                      "id": 32,
                      "projectName": "Project A.2",
                      "description": "",
                      "projectLevelId": 21,
                      "projectIdHook": 31,
                      "restProjectProcesses": []
                  },
                  {
                      "id": 36,
                      "projectName": "Project C.2",
                      "description": "",
                      "projectLevelId": 21,
                      "projectIdHook": 35,
                      "restProjectProcesses": []
                  }
              ]
          },
          {
              "id": 22,
              "sequenceNr": 3,
              "restProjects": [
                  {
                      "id": 34,
                      "projectName": "Projet B.4",
                      "description": "",
                      "projectLevelId": 22,
                      "projectIdHook": 33,
                      "restProjectProcesses": []
                  },
                  {
                      "id": 37,
                      "projectName": "Project C.3",
                      "description": "",
                      "projectLevelId": 22,
                      "projectIdHook": 36,
                      "restProjectProcesses": []
                  }
              ]
          },
          {
              "id": 23,
              "sequenceNr": 4,
              "restProjects": []
          }
      ]
  }
  </code></pre>