I have a class structure like this

```
abstract class A
class B extends A
class C extends A
class D extends A
class E extends A

```

and I have a collection of the various instances, for example:

```
val xs = List(new D, new B, new E, new E, new C, new B)

```

My question is, is there an elegant way to filter out some of the subclasses from the List? 

Let's say I want all instances except B's and C's. I can do it with a bunch of isInstanceOf's, or using collect like this:

```
val ys = (xs collect {
    case b: B => None
    case c: C => None
    case notBorC => notBorC
}).filter(_ != None).asInstanceOf[List[A]]

```

This works but it feels awkward, mostly because of the filter and cast. Is there a more elegant way? Less code is preferred, and I'd like to have a solution that doesn't need to be updated if I add more subclasses of A.