let $title := (db:open-id('TG-DTA-GerManC-stemming-ws', $node) /ancestor::*:TEI[1]//*:fileDesc)[1]//*:titleStmt[1]//*:title[1]
Do you think that the following query would return the expected result?
db:open-id('TG-DTA-GerManC-stemming-ws', $node)/ ancestor::*:TEI[1]/ descendant::*:fileDesc[1]/ descendant::*:titleStmt[1]/ descendant::*:title[1]
If yes, it may be the fastest version (can’t promise, though). If no, could you try to specify what the given query is supposed to return in natural language?
By the way, if you know that an element will only occur once, it may even be faster to get rid of the position predicate "[1]". Still, due to the many variants a location path can look like, and the variety of the input to be processed, I can’t give any guarantee for that.
Christian