def array_keys(space, w_arr, w_search=None, strict=False):
    """ Return all the keys or a subset of the keys of an array """
    lst = []
    with space.iter(w_arr) as itr:
        while not itr.done():
            w_key, w_val = itr.next_item(space)
            if w_search:
                if space.str_eq(w_val, w_search):
                    if not strict or w_val.tp == w_search.tp:
                        lst.append(w_key)
            else:
                lst.append(w_key)
    return space.new_array_from_list(lst)