# Looking for a key in a nested dict

**URL:** <https://discourse.julialang.org/t/looking-for-a-key-in-a-nested-dict/17211>\
**Category:** New to Julia\
**Created:** [November 6, 2018, 11:21am UTC](https://discourse.julialang.org/t/looking-for-a-key-in-a-nested-dict/17211 "2018-11-06T11:21:00Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [November 6, 2018, 1:16pm UTC](https://discourse.julialang.org/t/looking-for-a-key-in-a-nested-dict/17211/2 "2018-11-06T13:16:51Z")

</div>

Wouldn’t this be a classic case of recursion? This code can be easily modified to push multiple positive results to an array.

```julia
function retrieve(dict, key_of_interest)
        for (key, value) in dict
        if key == key_of_interest
        	return value
        end
        if value isa Dict
            return retrieve(value, key_of_interest)
        end
    end
end

```

---

_[View the full topic](https://discourse.julialang.org/t/looking-for-a-key-in-a-nested-dict/17211)._
