use `if not activity['data'].get('dataset'):` or better still `if activity['data'].get('dataset'):` and reverse the returns  it's easier to read