I have a nested list with depth 6. The items in the list are mathematical expressions. I want to find the positions of the unique items in the nested list. I have found the following, which works for a non-nested list:
positionDuplicates[list_] := GatherBy[Range@Length[list], list[[#]] &]
Ideally, the function would also count how many times the item is repeated in the nested list.