If the bill of material for a product contains components produced in-house, the costs must be estimated for these items first. Only then should we calculate the costs for the product itself into which the components are built. This is best achieved by estimating the costs for all components manufactured in-house, vertically along the tree structure, using a depth-first search. Once we have estimated the costs for all the components at one level, we can estimate the costs for the higher level product when we return to the next highest level of the tree structure