Refactored the context iteration for the traversind methods to Query::expand()