Use bottomUp traversal in check of ancestor in the BWSm algorithm