I was wondering if there was any way to access common parent node using Xpath.
sometext &
This seems complicated. Just try:
xquery version "3.0"; let $test := sometext sometext2 return ($test//*[.//b][.//d])[last()]
to get i.e. the clostest common ancestor