'Filters a sequence of states according to a filter_func.
:param filter_func: The filter function. Should take a state as input and return a boolean.
:param states:      A sequence of states.
:returns:           A tuple, with the first element the matching states and the second element the non-matching
states.'

@staticmethod
def _filter_states(filter_func, states):

    if (filter_func is None):
        return (states, [])
    l.debug('Filtering    %d    states', len(states))
    match = []
    nomatch = []
    for p in states:
        if filter_func(p):
            l.debug('...    state    %s    matched!', p)
            match.append(p)
        else:
            l.debug("...    state    %s    didn't    match!", p)
            nomatch.append(p)
    l.debug('...    returning    %d    matches    and    %d    non-matches', len(match), len(nomatch))
    return (match, nomatch)
