How can I build a hierarchy tree from flat data in JavaScript?
<p>I have a json data like this :</p>

<pre><code>Data = [{"Id":"1", "Name":"abc", "Parent":""}, {"Id":"2", "Name":"abc", "Parent":"1"},
{"Id":"3", "Name":"abc", "Parent":"2"},{"Id":"4", "Name":"abc", "Parent":"2"}]
</code></pre>

<p>I want to transform this data into hierarchy tree like this :</p>

<pre><code>root: {
        Id:"1",
        Name:"abc", 
        Parent:"",
        0: {
            Id:"2",
            Name:"abc",
            Parent:"1",
             0:{
                Id:"3",
                Name:"abc",
                Parent:"2",
             1:{
                Id:"4",
                Name:"adb",
                Parent:"2",
.....
}
</code></pre>

<p>Currently I have the idea only make it as the array object but that format won't work for me. Because I need this format for TreeTable in sapui5. </p>

<p>Thank you for your help.</p>
