It should be always checked in relation of current node (the lookup algorithm checks from the current node up to the root), otherwise object's properties inside objects will have a auto-generated prefix, even if it was been declared:

Consider the following mapping:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<serializer>
    <class name="Acme\Parent" xml-root-name="package">
        <xml-namespace uri="http://acme-parent.com"/>
        <property name="child" type="Acme\Child" />
    </class>
</serializer>

<?xml version="1.0" encoding="UTF-8"?>
<serializer>
    <class name="Acme\Child" xml-root-name="child">
        <xml-namespace uri="http://acme-child.com" prefix="dc" />
        <property name="data" type="string" xml-namespace="http://acme-child.com" />
    </class>
</serializer>
```

This is the current result:
```
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://acme-parent.com">
  <child xmlns:ns-04de78c1="http://acme-child.com">
    <ns-04de78c1:data xmlns:ns-04de78c1="http://acme-child.com"><![CDATA[lorem-ipsum]]></ns-04de78c1:data>
  </metadata>
</package>
```

This is the result doing the lookup in the current node and moving the call to `addNamespaceAttributes` in the method `startVisitingObject` out of the if statement:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://acme-parent.com">
  <child xmlns:dc="http://acme-child.com">
    <dc:data><![CDATA[lorem-ipsum]]></dc:data>
  </metadata>
</package>
```