Use getattr for None id check