@PaulWhite Did you have any insight on the hierarchyid question I noted above? I couldn't make head or tail of why it wasn't producing the optimization only when in a CTE.
As a "fun" exercise I thought I'd see if I could get the push down working.
It is a shame that it isn't working correctly as the query execution time can drop quite a lot with this predicate pushed down as shown in the execution timings below.
It is sometimes possible to get this working by
Fir...
But anyway, the optimization for the query in question is a fairly obvious one, given the ordpath structure, hence specific support for it in the parser. Being where it is, it's not very flexible, but common use makes it worthwhile.