def METHOD_NAME(obj, key):
    if obj is None:
        return
    if '.' in key:
        k1, k2 = key.split('.', 1)
        return METHOD_NAME(getattr(obj, k1, None), k2)
    else:
        return getattr(obj, key, None)