Allow much more flexible filtering.

Filter by ancestors and descendents, using either the union or intersection of the two.