You should be wary of this design anyway, because then your tree would consist of nodes of different types and your tree-traversal code will require dynamic dispatch. Probably it’s better to put the Union
in the field type directly, as in this definition of red–black trees in DataStructures.jl, so that all nodes in a given tree have the same type.
(Worse, with your sort of definition, the root node would encode the entire structure of the tree into its type. Not only would every node have a different type, but every tree structure would have a different type — you’d be trying to get the compiler to re-specialize your code for every distinct tree structure.)