if (attributePrefix != null && !newAlreadyDeclaredPrefixes.contains(attribute.getNamespace().getPrefix())) {
copyElement.addNamespace(attributePrefix, originalElement.getNamespaceForPrefix(attributePrefix).getURI());
newAlreadyDeclaredPrefixes.add(attributePrefix);
}
}
<BUG>for (Iterator i = copyElement.elements().iterator(); i.hasNext();) {
Element child = (Element) i.next();
</BUG>
addNeededNamespaceDeclarations(originalElement, child, newAlreadyDeclaredPrefixes);
}

if (attributePrefix != null && !newAlreadyDeclaredPrefixes.contains(attribute.getNamespace().getPrefix())) {
copyElement.addNamespace(attributePrefix, originalElement.getNamespaceForPrefix(attributePrefix).getURI());
newAlreadyDeclaredPrefixes.add(attributePrefix);
