             return self
         } else {
             let filtered = children.filter { $0.name == key }
-            return filtered.count > 0 ? filtered.first! : AEXMLElement(AEXMLElement.errorElementName, value: "element <\(key)> not found")
+            let errorElement = AEXMLElement(AEXMLElement.errorElementName, value: "element <\(key)> not found")
+            return filtered.count > 0 ? filtered.first! : errorElement
         }
     }
     

/**
    This is base class for holding XML structure.

    You can access its structure by using subscript like this: 
    `element["foo"]["bar"]` would return `<bar></bar>` element from `<element><foo><bar></bar></foo></element>` XML as an `AEXMLElement` object.
*/
public class AEXMLElement: NSObject {
    

        static let documentName = "AEXMLDocument"
    }
    
    /// Default options used by NSXMLParser
    public struct NSXMLParserOptions {
        var shouldProcessNamespaces = false
        var shouldReportNamespacePrefixes = false
