from typing import Iterable


def _variable_or_iterable_to_set(x):
  """
  Convert variable or iterable x to a frozenset.

  If x is None, returns the empty set.

  Arguments
  ---------
  x: None, str or Iterable[str]

  Returns
  -------
  x: frozenset[str]

  """
  if x is None:
    return frozenset([])

  if isinstance(x, str):
    return frozenset([x])

  if not isinstance(x, Iterable) or not all(isinstance(xx, str) for xx in x):
    raise ValueError(
        "{} is expected to be either a string or an iterable of strings"
        .format(x))

  return frozenset(x)