title: How to filter values in my generator expression
body: <p>My function below is calculating the depth of a nested dict.</p>
  
  <pre><code>#!/usr/bin/env python3
  
  def get_dict_depth(d, depth=0):
      if not isinstance(d, dict) or not d:
          return depth   
      return max(get_dict_depth(v, depth+1) if k != 'id' else depth for k, v in d.items())
  
  foobar = {
          "key1" : "val1",
          "key2" : {
              "id" : "val2"
              },
          "new_d" : {
              "key" : "val",
              "key2" : {
                  "id" : "blabla",
                  "key" : {
                      "id" : "blabla",
                      }
                  },
              }
          }
  
  depth = get_dict_depth(foobar)
  print("Depth %d" % depth)
  </code></pre>
  
  <p>I would like to modify it to not include keys that have the value <code>id</code> in the depth calculation. The program works if I use a ternary in the generator expression:</p>
  
  <pre><code>return max(get_dict_depth(v, depth+1) if k != 'id' else depth for k, v in d.items())
  </code></pre>
  
  <p>But I can't seem to make it work by filtering:</p>
  
  <pre><code>return max(get_dict_depth(v, depth+1) for k, v in d.items() if k != 'id')
  </code></pre>
  
  <p>Why isn't my filter working and how do I make it work?          </p>