Ah, that is an “artifact” of the way show is implemented. By trying to print the fields of any children, the parent is indeed referenced again, thus the output.
You can overload show(io::IO, n::TreeNode), i.e.
import Base: show
function show(io::IO, n::TreeNode)
str_parent = isnothing(n.parent) ? "no parent" : "with parent"
str_children = "$(length(children(n))) children"
print(io, "TreeNode($str_parent, $(n.name), $(nodevalue(n)), $str_children)")
end
julia> current
TreeNode(no parent, root, 0, 1 children)
julia> tr
Tree(TreeNode[TreeNode(no parent, root, 0, 1 children)])