Added support for ancestor queries.