from typing import Iterable
from typing import Any
from typing import List


def dedupe(items: Iterable[Any], only_neighbors: bool = False) -> List[Any]:
    """Deduplicate a list while keeping order

    If only_neighbors is True, dedupe will only check neighboring values
    """
    ret: List[Any] = []
    for item in items:
        if (only_neighbors and ret and ret[-1] != item) or item not in ret:
            ret.append(item)
    return ret