Sadly the scripting components are not great at providing tree features. In grasshopper proper data trees are stored inside a class called
GH_Structure<T> with a type constraint on
IGH_Goo. It was felt that that was needlessly complicated in scripting components, so a second tree class was created called
DataTree<T> with no type constraints. What you really want is for tree operations to not mess with the data inside the tree at all, only with the tree layout itself. This is not possible in scripting components, since they will convert a lot of data types into simpler types, ditching a bunch of information along the way.
You can’t make it work for booleans and integers because null-states are lost when converting to a struct. You can’t make it work for Points, Curves and Breps because reference information will be lost.