Choose the first node in trees by documentid and null parent_id
Choose the first node in trees by documentid and null parent_id

This fixes an issue with generating the collection tree json for a
collection that is also in another collection.

See #265

MANUAL-UPDATE: Need to replace tree_to_json sql function in existing db

Connexions/cnx-archive,Connexions/cnx-archive