When all the distinct pathkeys are redundant then there can only be, at most, 1 single distinct value. There may be many rows with that value, but we can remove those extra ones with a LIMIT 1 rather than troubling over needlessly uniquifing them.
I'm not sure if this case is common enough in practice, but since this patch is very straightforward and adds no more costs, I think it's worth doing.
I also have concerns about the 2 Limit nodes pointed by the comment inside the patch. Maybe we can check with limit_needed() and manually add the limit node only if there is no LIMIT clause in the origin query?