def lookup(source, *keys, **kw):
  """Successively looks up each key, returning the default keyword arg if a dead end is reached."""
  fallback = kw.get('default')
  try:
    for key in keys:
      source = source[key]
    return source
  except (KeyError, AttributeError, TypeError):
    return fallback