Add support for a treeRoot with value NULL

Previously you would get an SQL error when trying to insert a node into
a tree where treeRoot was NULL. Now it handles it fine.