 
     /// The inner text of the element, if it exists
     public var text: String {
-        return children
-            .map({ $0 as? TextElement })
-            .flatMap({ $0 })
-            .reduce("", { $0 + $1.text })
+        return children.reduce("", {
+            if let element = $1 as? TextElement {
+                return $0 + element.text
+            }
+
+            return $0
+        })
     }
 
     /// The inner text of the element and its children

    public var description: String {
        switch self {
        case .list(let list):
            return list.map { $0.description }.joined(separator: "")
        case .element(let elem):
            if elem.name == rootElementName {
                return elem.children.map { $0.description }.joined(separator: "")
            }

            return elem.description

    var index: Int

    var xmlChildren: [XMLElement] {
        return children.flatMap { $0 as? XMLElement }
    }

    /**
