Add "toArray" function

Designed to work seamlessly with the nested set model