Okay. First I'd try an update stats on the base table to make sure all the estimates are right.
Those aren't really duplicates based on the logic in the query. Notice the data in the typ column, on the rows where there are duplicates there is a row with a value of "blocked" and row with a value of "blocking". So the query needs to be changed to either not include the typ column in the final output or only include "blocked" in the UNION ALL section of the CTE.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question