Implementation of boa tree in ruby/postgres