Using an ActiveRecord relation, recursively traverse trees using a single SQL query.