Set the correct tree ID for root nodes (fixes #23)