declare function local:xq-ancestor($x as node()) as node()* {
($x,if ($x/..) then local:xq-ancestor($x/..) else ())
};
local:xq-ancestor(..)[self::]
local:xq-ancestor(.)[self::]
(let $here := . return
reverse(root()/descendant::[. << $here][not(descendant::node()[. is $here])]))
(let $here := . return
reverse(../[. << $here]))
/.
(let $here := . return
root()/descendant::[. >> $here] except descendant::)
(let $here := . return
../[. >> $here])