             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
         }
     }
     

        :param: encoding Encoding value for XML Document header (defaults to "utf-8").
        :param: standalone Standalone value for XML Document header (defaults to "no").
        :param: xmlData XML data to parse.
        :param: error If there is an error reading in the data, upon return contains an `NSError` object that describes the problem.
    
        :returns: An initialized XML Document object containing the parsed data. Returns `nil` if the data could not be parsed.
    */
    public convenience init(version: Double = Defaults.version, encoding: String = Defaults.encoding, standalone: String = Defaults.standalone, xmlData: NSData, xmlParserOptions: NSXMLParserOptions = NSXMLParserOptions()) throws {
        self.init(version: version, encoding: encoding, standalone: standalone, xmlParserOptions: xmlParserOptions)
        try loadXMLData(xmlData)
    }

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