def build_attribute_dict(items, attr_name):
    """Build a dict from a list of items and one of their attributes to make
    querying the collection easier.
    """
    attr_dict = {}
    for item in items:
        attr_dict[getattr(item, attr_name)] = item
    return attr_dict