Of course you can use your original approach, but it would be more suitable to apply multiple dispatch:
mutable struct node{T}
data::T
left::Union{Nothing, node}
right::Union{Nothing, node}
end
node(x::T) where T = node{T}(x, nothing, nothing)
height(root::Nothing) = 0
height(root) = max(height(root.left), height(root.right)) + 1
Note also, that while type is Nothing object of this type is nothing