Create a tree structure and update the parent with its child values