SQL Server, recursive bottom up BOM possible inventory calculation AdventureWorks

I want to write some recursive logic to calculate the possible stock/inventory of a bill of materials.

As test environment, I use the AdventureWorks database. At the moment I know I must calculate from bottom up, so every component in my BOM has its own warehouse stock, and additionally a calculated possible stock, from his own components, but this calculated stock is dependent on the lowest stock (MIN) of his components stock divided by the QuantityPerAssembly.

So my problem is the grouping and calculation from bottom up, any ideas?