Builds parent-child relationship from children