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

      case let type as Y:
        return other(type)

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

      case let type as T:
        return filter(type)

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

      default:
