Cleaning up __keys__() slightly to remove minor code duplication.