Using Dict() to directly define variables

Inspired by this article "Time Series Structure Discovery via Probabilistic Program Synthesis, I wanted to use a dictionary to store a tree of random variables and operations. Below model1 works; model2 fails with "VarName: Mis-formed variable name (m[:top]).var1!".

using Turing

mutable struct ModelNode
    isleaf::Bool
    op::Symbol
    left::ModelNode
    right::ModelNode
    var1
    var2
    var3
end

@model modeltree1() = begin

    m = Dict{Symbol, ModelNode}()

    σ ~ InverseGamma(2,3)
    μ ~ Normal(0,sqrt(σ))
    x ~ Normal(μ, sqrt(σ))
    
    m[:top] = ModelNode(isleaf = true)
    m[:top].var1 = σ
    m[:top].var2 = μ
    m[:top].var3 = x

    return m[:top].var3
end

@model modeltree2() = begin

    m = Dict{Symbol, ModelNode}()

    m[:top] = ModelNode(isleaf = true)
    # σ
    m[:top].var1 ~ InverseGamma(2,3)
    # μ
    m[:top].var2 ~ Normal(0,sqrt(m[:top].var1))
    # variable
    m[:top].var3 ~ Normal(m[:top].var2, sqrt(m[:top].var1))

    return m[:top].var3
end

Any idea why this would be the case?

More generally, if anybody is familiar with this paper, do you think that Turing is actually the right library to use (versus Soss or Gen)?

Thank.