code: def _get_entity_recursive(json, entity):
      if not json:
          return None
      elif isinstance(json, dict):
          for key, value in json.items():
              if key == entity:
                  return value
              # 'entities' and 'extended_entities' are wrappers in Twitter json
              # structure that contain other Twitter objects. See:
              # https://dev.twitter.com/overview/api/entities-in-twitter-objects
  
              if key == "entities" or key == "extended_entities":
                  candidate = _get_entity_recursive(value, entity)
                  if candidate is not None:
                      return candidate
          return None
      elif isinstance(json, list):
          for item in json:
              candidate = _get_entity_recursive(item, entity)
              if candidate is not None:
                  return candidate
          return None
      else:
          return None
  
file_path: nltk/nltk/twitter/common.py
imports: import csv
  import gzip
  import json
  from nltk.internals import deprecated
label_desc: Use image node_id 5 for calling a global function with example usage: _get_entity_recursive(json, entity) and returns: None, None, None, None, value, candidate, candidate