Get the level of a hierarchy
问题 I have an array of objects, Where each object has an id and a ParentId property (so they can be arranged in trees). They are in no particular order. Please note that the id 's and parentId 's will not be integers, they will be strings (just wanted to have the sample code cleaner..) There is only one root: lets say its id :1 The data looks like so: data = [ { id:"id-2", parentId:"id-3" }, { id:"id-4", parentId:"2" }, { id:"id-3", parentId:"id-4" }, { id:"id-5", parentId:"id-4" }, { id:"id-6",