Fixed the XPath prefixing when the query wraps a union in braces

If the XPath query is using braces around a union, the logic applying the prefix currently generates a broken query.

I discovered the bug while working on https://github.com/symfony/symfony/pull/10935 which also performs a transformation of XPath queries (more complex than applying a prefix) when running it against the BrowserKitDriver testuite, where we have such queries with braces in them (coming from the Manipulator)