def dedupe(items: list, only_neighbors: bool=False) ->list:
    """
    Deduplicate a list while keeping order
    
    If only_neighbors is True, dedupe will only check neighboring values
    """
    ret = []
    for item in items:
        if only_neighbors and ret and ret[-1] != item or item not in ret:
            ret.append(item)
    return ret
