<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def smallest(heap, predicate):
 """Finds the index of the smallest item in the heap that matches the given predicate. :param heap: Heap on which this search is being performed. :param predicate: Function that accepts an item from the heap and returns true or false. :returns: Index of the first item for which ``predicate`` returned true. :raises NoMatchError: If no matching items were found. """

    n = heap.size()

    # items contains indexes of items yet to be checked.
    items = deque([0])
    while items:
        current = items.popleft()
        if current >= n:
            continue

        if predicate(heap.peek(current)):
            return current

        child1 = 2 * current + 1
        child2 = child1 + 1

        if child1 < n and child2 < n and heap.lt(child2, child1):
            # make sure we check the smaller child first.
            child1, child2 = child2, child1

        if child1 < n:
            items.append(child1)

        if child2 < n:
            items.append(child2)

    raise NoMatchError()