'Query the properties values of |HasProps| instances with a
predicate.
Args:
query (callable) :
A callable that accepts property descriptors and returns True
or False
include_defaults (bool, optional) :
Whether to include properties that have not been explicitly
set by a user (default: True)
Returns:
dict : mapping of property names and values for matching properties'

def query_properties_with_values(self, query, include_defaults=True):

    themed_keys = set()
    result = dict()
    if include_defaults:
        keys = self.properties()
    else:
        keys = (set(self._property_values.keys()) | set(self._unstable_default_values.keys()))
        if self.themed_values():
            themed_keys = set(self.themed_values().keys())
            keys |= themed_keys
    for key in keys:
        descriptor = self.lookup(key)
        if (not query(descriptor)):
            continue
        value = descriptor.serializable_value(self)
        if ((not include_defaults) and (key not in themed_keys)):
            if (isinstance(value, PropertyValueContainer) and (key in self._unstable_default_values)):
                continue
        result[key] = value
    return result
