The last query seems to be different than the others. Not only has it been refactored, but it also seems to be simplified: it misses the path through ?location and ?locationId. That could well explain why this query runs so much faster. To analyze the (lack of) performance for the first query, I 'll need some data to test with. This very much looks like a query optimization issue related to expected result counts of query parts.
The query optimizer has been improved to resolve this issue. Query models with JOIN-UNION-JOIN combinations are now normalized to a UNION-JOIN-JOIN form. The existing join reordering is then applied to the JOIN-JOIN combination. Finally, the query optimizer checks if the left-most JOIN argument can be factered out again, pushing the UNION lower in the query model tree. This last step is only possible if the JOIN order did not change in the second step, or if they changed in a similar way.