Get value in nested data structure of arbitrary depth

A combination of dispatch and recursion would work:

get_value(data::NamedTuple, k::Symbol) = getproperty(data, k)
get_value(data::AbstractVector, k::Int) = getindex(data, k)
function get_value(data, k::Tuple)
    if length(k) == 0
        data
    else
        get_value(get_value(data, k[1]), k[2:end])
    end
end

Alternatively, you could just use a loop:

function get_value2(data, ks)
    for k in ks
        data = get(data, k, missing)  # get works for many types and handles missing keys
    end
    data
end
2 Likes