Organise ActiveRecord model into a tree structure (fork with modifications in allow-string-ids branch)