private static function addEntityQueryCondition(QueryInterface &$query, $key, $value) {
    $simple = array(
      'from' => ['timestamp', '>='],
      'to' => ['timestamp', '<'],
    );

    if (isset($simple[$key])) {
      list($field, $op) = $simple[$key];
      $query->condition($field, $value, $op);
      return;
    }

    $query->condition($key, $value);
  }