Better pattern for checking for key existence in dictionaries