Review this Go function that prices a bill of materials by recursively expanding sub-assemblies. Deep trees with shared sub-assemblies are extremely slow.