The "random" nodes are not unimportant, they significantly affect the answer.
Trouble is, you're using terminology imprecisely. When you say "preceding", I suspect you are not using the word in the sense of the XPath preceding axis. You are also using "node" when referring to source XML rather than to the tree model.
The expression
(ancestor::subparagraph)[last()]
finds the innermost enclosing subparagraph element of the context node. This looks like the right thing from what I can see, but the information you've given is very incomplete.
There could be other things wrong: you might be at the wrong context node, there might be namespaces in force, ...
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference