So, I want to have explainable equations derived from replacement rules.

I made a Mathematica function that does the following, it takes a list of rules, and it applies them (using ReplaceAll), then it gives a list of the rules being taken step by step.

```
FormattedRules({r -> 3, z -> 5,
y -> 3, <|"rule" -> x -> Sqrt((z + y)/r), "numeric" -> True|>})
(*
{HoldForm(r == 3), HoldForm(z == 5), HoldForm(y == 3),
HoldForm(x == Sqrt((y + z)/r) == 2*Sqrt(2/3) == 1.632993161855452)}
*)
```

This works pretty well, however, there might be a rule with multiple cases, say `{{z->5},{z->-5}}`

. This of course, produces a branch, of a tree, since I’m saving all the intermediary steps, that means that all intermediary steps should be saved as well.

So, I want to convert for example the following:

```
{y->5,{x->y^2,x->y+3},z->2x}
```

into

```
{{y->5,x->y^2,z->2x},{y->5,x->y+3,z->2x}}
```

Or for example a more nested example

```
{{y->5,y->1},{x->y^2,x->y+3},z->2x}
```

into

```
{{{y->5,x->y^2,z->2x},{y->5,x->y+3,z->2x}},{{y->1,x->y^2,z->2x},{y->1,x->y+3,z->2x}}}
```

In order to do this I thought about using a tree, but I discovered that trees are not implemented in mathematica, natively. So before creating my own custom functions I figured out, maybe someone knows a less error prone way to approach the problem?