def flatten(arr, type):
    """Flatten an array of type."""
    res = []
    for i in arr:
        if isinstance(i, type):
            res.append(i)
        else:
            res.extend(flatten(i, type))
    return res