I currently have this object:
var obj = {
    1: {
    title: 'test',
    children: {
        2: {
        title: 'test2',
        children: {}
      },
      3: {
        title: 'test3',
        children: {}
      }
    }
  }
};
The whole idea is I make a function to add an item to this object. As parameter I send the parent.
Now, I was wondering how I would get the right item object. For example if I send parent '2', it would get 2: from the children of 1:. The only way I can think of is a for loop, but I don't know if there's a more efficient way. The children can be extended even more, so a parent has children, those children have children endlessly. That's the whole idea at least.
I think with a few items a for loop is okay, but I think if I have over 50 items it's already slow, and it'll even be slower with more.
 
     
     
    