attempting to make xpath impl smart (unstable/tested)