R - Filtering list of nested lists and finding back a higher level key
<p>I am working on parsing a JSON containing API info for several accounts. This data is used in an api wrapper.</p>

<pre><code>[
    {
        "geo":"au",
        "api": [
            {"type":"base_url", "value":"https://api.com"},
            {"type":"key", "value":"f18"},
            {"type":"secret", "value":"569"}
        ],
        "accounts": [
            {"name":"client_AQE","id":"8765","inventory":"all","currency":"AUD"}
       ]
    },{
        "geo":"eu",
        "api": [
            {"type":"base_url", "value":"https://api.com"},
            {"type":"key", "value":"p8c6043"},
            {"type":"secret", "value":"983df5"}
        ],
        "accounts": [
            {"name":"client_UYT","id":"098765","inventory":"all","currency":"GBP"},
            {"name":"client_WER","id":"09098","inventory":"all","currency":"GBP"},
            {"name":"client_OIP","id":"234543","inventory":"all","currency":"EUR"}
        ]
    }
]
</code></pre>

<p>When the user give me a "account name" but doesn't specify the "geo", I would like to:</p>

<ol>
<li>Check if the client only appears once (this can be done with the function below, using <code>rlist</code>)</li>
</ol>

<blockquote>
<pre><code>only_one_client &lt;- function(account_name) {
  return(fromJSON(file=API_INFO_PATH) %&gt;% 
           list.map(accounts) %&gt;% 
           unlist(recursive=F) %&gt;% 
           list.mapv(name) %&gt;% table() %&gt;% extract(account_name) == 1))
}
</code></pre>
</blockquote>

<ol start="2">
<li>If the client only appears once, find the "geo" it appears in</li>
</ol>

<blockquote>
  <p><strong>This is what I cannot find a way to do</strong></p>
</blockquote>