def matches(item, *, plugins=None, subregions=None):
    """
    Checks whether the item matches zero or more constraints.

    ``plugins`` should be a tuple of plugin classes or ``None`` if the type
    shouldn't be checked.

    ``subregions`` should be set of allowed ``subregion`` attribute values or
    ``None`` if the ``subregion`` attribute shouldn't be checked at all.
    Include ``None`` in the set if you want ``matches`` to succeed also when
    encountering an item without a ``subregion`` attribute.
    """
    if plugins is not None and not isinstance(item, plugins):
        return False
    if subregions is not None and getattr(item, "subregion", None) not in subregions:
        return False
    return True