Logic for dependecies

I have a list of parameters and a list of dependencies:
I want to create a list of dependencies for each parameter, up to the initial level.
See below the example:

Parameter dependencies Final result
Param1 A-Param2 A-K-L-O-B-C
Param2 Param3-B-C K-L-O-B-C
Param3 K-L-O K-L-O
Param4 Param3-G K-L-O-G
Param5 Param2-Param7 K-L-O-B-C-T
Param7 T T

Dynamo code nodes are able to resolve variables which incorporate other variables as they are associative.
From the DesignScript Guide:

Associativity is a feature in DesignScript that allows the propagation of a change of variable to all dependent statements in the program. The propagation of change happens at runtime and is handled by the update mechanism of the DesignScript virtual machine

Two possible solutions

1 Like

Thank you.
I have two lists: how can I assign the parameter to the dependencies? Can I use a dictionary? i have sometimes many Param.