Allow tree_id to be manually set

This will fix #189. See my comment on that bug for my rationale.

Included changes to docs and a test case (uses a foreign key).