Add support for filter inside HasChild and HasParent filter.

A HasChild and HasParent filter currently only accepts a query. This pull request adds support for using a filter.