final protected function applyOperator(\SelectQueryInterface $query, $statement, $value)
    {
        // Check if $value contains an operator (i.e. if is associative array)
        if (is_array($value) && !Misc::isIndexed($value)) {

            // First key will be the operator
            $keys     = array_keys($value);
            $operator = $keys[0];
            $value    = $value[$operator];

            switch ($operator) {

                case '<>':
                    if (is_array($value)) {
                        $query->condition($statement, $value, 'NOT IN');
                    } else {
                        $query->condition($statement, $value, '<>');
                    }
                    break;

                case 'exists':
                    $query->exists($value);
                    break;

                case 'in':
                    $query->condition($statement, $value, 'IN');
                    break;

                default:
                    $query->condition($statement, $value, $operator);
                    break;
            }
        } else if (null === $value) {
            $query->isNull($statement);
        } else {
            $query->condition($statement, $value);
        }
    }