Use the xpath axis preceding-siblingas follows:
preceding-sibling::w:r[1]/w:fldChar/@w:fldCharType = 'end'
which will select the nearest ( [1]) preceding-siblingwith a name w:r, then go down to any child element (s) with a name w:fldChar, then any attributes from there will be named w:fldCharType, then if any such node exists, the text of which 'end'returns true.