In tree grid view, how do I calculate and show global scope ratio of my BOM tree ?

Hi, expert

In case like image below,how do I calculate the global scope ratio of my BOM and display the result with query builder and tree grid view ?

The local scope ratio is recorded in relationship(item type) , because each items ( PartI,PartII,Mat1,Mat2,,,)  is used in other bom.

It's difficult for me to pass the superior value in relationship of the tree diagram to next relationship.

(2 layer under: Item - Relationship (superior value) - Item - Relationship (Target) ) .

Please give me some advise.

sorry for my cheap image...