Improving performance, by using hashes instead of arrays in the :visit_ancestors method