You can skip the check for the key and just do `if obj['samples'].get(key, {}).get('status') == 'doc_not_found'`, which is a little shorter. But perhaps less clear, I suppose.