Returns the first element of 'property-sets' which is a subset of
    'properties', or an empty list if no such element exists.

def find_satisfied_condition(conditions, ps):
    """Returns the first element of 'property-sets' which is a subset of
    'properties', or an empty list if no such element exists."""
    assert is_iterable_typed(conditions, property_set.PropertySet)
    assert isinstance(ps, property_set.PropertySet)

    for condition in conditions:

        found_all = True
        for i in condition.all():

            if i.value:
                found = i.value in ps.get(i.feature)
            else:
                # Handle value-less properties like '<architecture>' (compare with
                # '<architecture>x86').
                # If $(i) is a value-less property it should match default
                # value of an optional property. See the first line in the
                # example below:
                #
                #  property set     properties     result
                # <a> <b>foo      <b>foo           match
                # <a> <b>foo      <a>foo <b>foo    no match
                # <a>foo <b>foo   <b>foo           no match
                # <a>foo <b>foo   <a>foo <b>foo    match
                found = not ps.get(i.feature)

            found_all = found_all and found

        if found_all:
            return condition

    return None