def _index_matching_predicate(seq, pred):
    """Return index of first item matching predicate.

    Args:
        seq - a list.
        pred - a function with one argument, returning True or False.

    Returns:
        index or None
    """
    for i, v in enumerate(seq):
        if pred(v):
            return i
    return None