Tree behavior for ActiveRecord models and Mongoid documents.