Parent-Child Hierarchy w/ multiple parents -> update

Dear community,

I thought my problem was solved in this topic:

Parent-Child Hierarchy w/ multiple parents - KNIME Analytics Platform - KNIME Community Forum

But I encountered an issue that a child can be in different hierarchy levels and then the wf does not work properly.

If I input in the table following data in the table creator

parent | child

A | K

A | L

A | M

K | R

K | S

K | T

L | U

L | V

L | W

R | X

R | Y

R | Z

B | L

B | M

B | R

B | S

B | T

The result for top parent A misses the children of the last level (X,Y,Z) because their next parent R is in top parent A relation under K, but in top parent relation B the child R is directly under B.

Would be great if anybody could find a solution for that.

Thank you very much in advance and best regards