protected function getSelectedOptions(FieldItemListInterface $items, $delta = 0) {
    // We need to check against a flat list of options.
    $options = $this->getOptions($items->getEntity());

    $selected_options = [];
    foreach ($items as $item) {
      $value = $item->{$this->column};
      // Keep the value if it actually is in the list of options (needs to be
      // checked against the flat list).
      if (isset($options[$value])) {
        $selected_options[] = $value;
      }
    }

    return $selected_options;
  }