private void CopyNamespacesHelper(XPathNavigator navigator, XPathNamespaceScope nsScope) {
string prefix = navigator.LocalName;
string ns = navigator.Value;
if (navigator.MoveToNextNamespace(nsScope))
CopyNamespacesHelper(navigator, nsScope);
// No possibility for conflict, since we're copying namespaces from well-formed element
WriteNamespaceDeclarationUnchecked(prefix, ns);
}