Don't query database needlessly in get_ancestors.