Tranforming from relationships to hierarchy in Excel with Power Query

I have a table that looks like this:

id name level fromId fromName toId toName
1 A 1 1 A 3 B
2 A 1 1 C 4 C
3 B 2 3 B 6 D
4 C 2 4 C 7 E
5 C 2 5 C 8 F
6 D 3
7 E 3
8 F 3

I’m trying to find a way to pivot it and show the hierarchy like this:

1 2 3
A B D
A C E
A C F

But I can’t figure out how to do this with Power Query. Any idea?