       case let type as Y:
         return other(type)
 
-      case let array as NSArray:
-        if array.firstObject is T {
+      case let array as Array<Any>:
+        if array.first is T {
           return array.flatMap { $0 as? T }.filter(filter)
         } else {
           return array.flatMap { $0 as? Y }.filter(other)

      case let type as Y:
        return other(type, arg)

      case let array as NSArray:
        if array.firstObject is T {
          return array.flatMap { $0 as? T }.filter({ filter($0, arg) })
        } else {
          return array.flatMap { $0 as? Y }.filter({ other($0, arg) })

      case let type as T:
        return filter(type)

      case let array as Array<Any>:
        return array.flatMap { $0 as? T }.filter(filter)

      default:
