Fixes the bug XPath causing pop from empty stack