Sane tree builder for ActiveRecord and PostgreSQL