This is a tough one.
As a start, take your PruneDuplicates node and get the first index of each item in each sublist with a List.AllIndicesOf node and some crossproduct lacing at level 2 and keeping the list structure. The next steps should start to unravel from there.