import copy


def util_remove(context, array, item):
    """
    given a list, remove matching item.

    :param: context: held by the ast, contains api and
                     other context sensitive data
    :param: array: list to remove items from
    :param: item: item to remove from array

    :returns: modified list
    """

    if array is None:
        return None

    if not isinstance(array, list):
        raise SyntaxError('remove on non-list type')

    newlist = copy.deepcopy(array)

    if item in newlist:
        newlist.remove(item)

    return newlist