plugins types UPDATE compare callback assumes realtypes are the same

There is no reason the callbacks should need to
handle this situation.
diff --git a/src/plugins_types.c b/src/plugins_types.c
index 966b25a..de7273d 100644
--- a/src/plugins_types.c
+++ b/src/plugins_types.c
@@ -307,10 +307,6 @@
 LIBYANG_API_DEF LY_ERR
 lyplg_type_compare_simple(const struct lyd_value *val1, const struct lyd_value *val2)
 {
-    if (val1->realtype != val2->realtype) {
-        return LY_ENOT;
-    }
-
     if (val1->_canonical == val2->_canonical) {
         return LY_SUCCESS;
     }
@@ -1058,6 +1054,9 @@
             if (set.val.nodes[i].type != LYXP_NODE_ELEM) {
                 continue;
             }
+            if (((struct lyd_node_term *)set.val.nodes[i].node)->value.realtype != value->realtype) {
+                continue;
+            }
 
             if (!lref->plugin->compare(&((struct lyd_node_term *)set.val.nodes[i].node)->value, value)) {
                 break;
diff --git a/src/plugins_types.h b/src/plugins_types.h
index 594f755..b4ecd43 100644
--- a/src/plugins_types.h
+++ b/src/plugins_types.h
@@ -523,7 +523,7 @@
  * @param[in] tree External data tree (e.g. when validating RPC/Notification) with possibly referenced data.
  * @param[in,out] storage Storage of the value successfully filled by ::lyplg_type_store_clb. May be modified.
  * @param[out] err Optionally provided error information in case of failure. If not provided to the caller, a generic
- *             error message is prepared instead. The error structure can be created by ::ly_err_new().
+ * error message is prepared instead. The error structure can be created by ::ly_err_new().
  * @return LY_SUCCESS on success,
  * @return LY_ERR value on error.
  */
@@ -533,12 +533,12 @@
 /**
  * @brief Callback for comparing 2 values of the same type.
  *
- * In case the value types (::lyd_value.realtype) are different, ::LY_ENOT must always be returned.
- * It can be assumed that the same context (dictionary) was used for storing both values.
+ * It can be assumed that the same context (dictionary) was used for storing both values and the realtype
+ * member of both the values is the same.
  *
  * @param[in] val1 First value to compare.
  * @param[in] val2 Second value to compare.
- * @return LY_SUCCESS if values are same (according to the type's definition of being same).
+ * @return LY_SUCCESS if values are considered equal.
  * @return LY_ENOT if values differ.
  */
 typedef LY_ERR (*lyplg_type_compare_clb)(const struct lyd_value *val1, const struct lyd_value *val2);
diff --git a/src/plugins_types/binary.c b/src/plugins_types/binary.c
index 519ec2e..542b54b 100644
--- a/src/plugins_types/binary.c
+++ b/src/plugins_types/binary.c
@@ -340,10 +340,6 @@
 {
     struct lyd_value_binary *v1, *v2;
 
-    if (val1->realtype != val2->realtype) {
-        return LY_ENOT;
-    }
-
     LYD_VALUE_GET(val1, v1);
     LYD_VALUE_GET(val2, v2);
 
diff --git a/src/plugins_types/bits.c b/src/plugins_types/bits.c
index 04adace..2f87ed3 100644
--- a/src/plugins_types/bits.c
+++ b/src/plugins_types/bits.c
@@ -373,10 +373,6 @@
     struct lyd_value_bits *v1, *v2;
     struct lysc_type_bits *type_bits = (struct lysc_type_bits *)val1->realtype;
 
-    if (val1->realtype != val2->realtype) {
-        return LY_ENOT;
-    }
-
     LYD_VALUE_GET(val1, v1);
     LYD_VALUE_GET(val2, v2);
 
diff --git a/src/plugins_types/boolean.c b/src/plugins_types/boolean.c
index f8b19f6..415b8b9 100644
--- a/src/plugins_types/boolean.c
+++ b/src/plugins_types/boolean.c
@@ -106,10 +106,6 @@
 LIBYANG_API_DEF LY_ERR
 lyplg_type_compare_boolean(const struct lyd_value *val1, const struct lyd_value *val2)
 {
-    if (val1->realtype != val2->realtype) {
-        return LY_ENOT;
-    }
-
     if (val1->boolean != val2->boolean) {
         return LY_ENOT;
     }
diff --git a/src/plugins_types/date_and_time.c b/src/plugins_types/date_and_time.c
index 0530f29..594b0a8 100644
--- a/src/plugins_types/date_and_time.c
+++ b/src/plugins_types/date_and_time.c
@@ -153,10 +153,6 @@
 {
     struct lyd_value_date_and_time *v1, *v2;
 
-    if (val1->realtype != val2->realtype) {
-        return LY_ENOT;
-    }
-
     LYD_VALUE_GET(val1, v1);
     LYD_VALUE_GET(val2, v2);
 
diff --git a/src/plugins_types/decimal64.c b/src/plugins_types/decimal64.c
index 25a88d9..cbd6934 100644
--- a/src/plugins_types/decimal64.c
+++ b/src/plugins_types/decimal64.c
@@ -161,10 +161,6 @@
 LIBYANG_API_DEF LY_ERR
 lyplg_type_compare_decimal64(const struct lyd_value *val1, const struct lyd_value *val2)
 {
-    if (val1->realtype != val2->realtype) {
-        return LY_ENOT;
-    }
-
     /* if type is the same, the fraction digits are, too */
     if (val1->dec64 != val2->dec64) {
         return LY_ENOT;
diff --git a/src/plugins_types/identityref.c b/src/plugins_types/identityref.c
index 0a1fa32..588a969 100644
--- a/src/plugins_types/identityref.c
+++ b/src/plugins_types/identityref.c
@@ -303,10 +303,6 @@
 LIBYANG_API_DEF LY_ERR
 lyplg_type_compare_identityref(const struct lyd_value *val1, const struct lyd_value *val2)
 {
-    if (val1->realtype != val2->realtype) {
-        return LY_ENOT;
-    }
-
     if (val1->ident == val2->ident) {
         return LY_SUCCESS;
     }
diff --git a/src/plugins_types/instanceid.c b/src/plugins_types/instanceid.c
index 3971c36..c15ff64 100644
--- a/src/plugins_types/instanceid.c
+++ b/src/plugins_types/instanceid.c
@@ -257,10 +257,6 @@
 {
     LY_ARRAY_COUNT_TYPE u, v;
 
-    if (val1->realtype != val2->realtype) {
-        return LY_ENOT;
-    }
-
     if (val1 == val2) {
         return LY_SUCCESS;
     } else if (LY_ARRAY_COUNT(val1->target) != LY_ARRAY_COUNT(val2->target)) {
diff --git a/src/plugins_types/integer.c b/src/plugins_types/integer.c
index 0903365..05d6801 100644
--- a/src/plugins_types/integer.c
+++ b/src/plugins_types/integer.c
@@ -373,10 +373,6 @@
 LIBYANG_API_DEF LY_ERR
 lyplg_type_compare_uint(const struct lyd_value *val1, const struct lyd_value *val2)
 {
-    if (val1->realtype != val2->realtype) {
-        return LY_ENOT;
-    }
-
     switch (val1->realtype->basetype) {
     case LY_TYPE_UINT8:
         if (val1->uint8 != val2->uint8) {
diff --git a/src/plugins_types/ipv4_address.c b/src/plugins_types/ipv4_address.c
index f7b297c..9e54a0b 100644
--- a/src/plugins_types/ipv4_address.c
+++ b/src/plugins_types/ipv4_address.c
@@ -214,10 +214,6 @@
 {
     struct lyd_value_ipv4_address *v1, *v2;
 
-    if (val1->realtype != val2->realtype) {
-        return LY_ENOT;
-    }
-
     LYD_VALUE_GET(val1, v1);
     LYD_VALUE_GET(val2, v2);
 
diff --git a/src/plugins_types/ipv4_address_no_zone.c b/src/plugins_types/ipv4_address_no_zone.c
index 91fe677..a693912 100644
--- a/src/plugins_types/ipv4_address_no_zone.c
+++ b/src/plugins_types/ipv4_address_no_zone.c
@@ -132,10 +132,6 @@
 {
     struct lyd_value_ipv4_address_no_zone *v1, *v2;
 
-    if (val1->realtype != val2->realtype) {
-        return LY_ENOT;
-    }
-
     LYD_VALUE_GET(val1, v1);
     LYD_VALUE_GET(val2, v2);
 
diff --git a/src/plugins_types/ipv4_prefix.c b/src/plugins_types/ipv4_prefix.c
index 6f13eee..b8d77b5 100644
--- a/src/plugins_types/ipv4_prefix.c
+++ b/src/plugins_types/ipv4_prefix.c
@@ -203,10 +203,6 @@
 {
     struct lyd_value_ipv4_prefix *v1, *v2;
 
-    if (val1->realtype != val2->realtype) {
-        return LY_ENOT;
-    }
-
     LYD_VALUE_GET(val1, v1);
     LYD_VALUE_GET(val2, v2);
 
diff --git a/src/plugins_types/ipv6_address.c b/src/plugins_types/ipv6_address.c
index 74f5c62..344a7fc 100644
--- a/src/plugins_types/ipv6_address.c
+++ b/src/plugins_types/ipv6_address.c
@@ -216,10 +216,6 @@
 {
     struct lyd_value_ipv6_address *v1, *v2;
 
-    if (val1->realtype != val2->realtype) {
-        return LY_ENOT;
-    }
-
     LYD_VALUE_GET(val1, v1);
     LYD_VALUE_GET(val2, v2);
 
diff --git a/src/plugins_types/ipv6_address_no_zone.c b/src/plugins_types/ipv6_address_no_zone.c
index 26fbf80..98ca754 100644
--- a/src/plugins_types/ipv6_address_no_zone.c
+++ b/src/plugins_types/ipv6_address_no_zone.c
@@ -180,10 +180,6 @@
 {
     struct lyd_value_ipv6_address_no_zone *v1, *v2;
 
-    if (val1->realtype != val2->realtype) {
-        return LY_ENOT;
-    }
-
     LYD_VALUE_GET(val1, v1);
     LYD_VALUE_GET(val2, v2);
 
diff --git a/src/plugins_types/ipv6_prefix.c b/src/plugins_types/ipv6_prefix.c
index 8e62311..aaec395 100644
--- a/src/plugins_types/ipv6_prefix.c
+++ b/src/plugins_types/ipv6_prefix.c
@@ -217,10 +217,6 @@
 {
     struct lyd_value_ipv6_prefix *v1, *v2;
 
-    if (val1->realtype != val2->realtype) {
-        return LY_ENOT;
-    }
-
     LYD_VALUE_GET(val1, v1);
     LYD_VALUE_GET(val2, v2);
 
diff --git a/src/plugins_types/union.c b/src/plugins_types/union.c
index bb6d4b0..a5b7610 100644
--- a/src/plugins_types/union.c
+++ b/src/plugins_types/union.c
@@ -423,10 +423,6 @@
 LIBYANG_API_DEF LY_ERR
 lyplg_type_compare_union(const struct lyd_value *val1, const struct lyd_value *val2)
 {
-    if (val1->realtype != val2->realtype) {
-        return LY_ENOT;
-    }
-
     if (val1->subvalue->value.realtype != val2->subvalue->value.realtype) {
         return LY_ENOT;
     }
diff --git a/tests/utests/types/bits.c b/tests/utests/types/bits.c
index 4b39a1e..eb40965 100644
--- a/tests/utests/types/bits.c
+++ b/tests/utests/types/bits.c
@@ -949,30 +949,6 @@
     assert_int_equal(LY_ENOT,    type->compare(&diff_type_val, &(values[1])));
     type->free(UTEST_LYCTX, &(diff_type_val));
 
-    /*
-     * derivated type add some limitations
-     */
-    diff_type_text = val_init[2];
-    diff_type = ((struct lysc_node_leaf *)mod->compiled->data->next->next)->type;
-    ly_ret = diff_type->plugin->store(UTEST_LYCTX, diff_type, diff_type_text, strlen(diff_type_text),
-            0, LY_VALUE_XML, NULL, LYD_VALHINT_STRING, NULL, &diff_type_val, NULL, &err);
-    assert_int_equal(LY_SUCCESS, ly_ret);
-    assert_int_equal(LY_ENOT, type->compare(&diff_type_val, &(values[2])));
-    assert_int_equal(LY_ENOT, type->compare(&diff_type_val, &(values[1])));
-    type->free(UTEST_LYCTX, &(diff_type_val));
-
-    /*
-     * different type (STRING)
-     */
-    diff_type_text = val_init[2];
-    diff_type = ((struct lysc_node_leaf *)mod->compiled->data->next->next->next)->type;
-    ly_ret = diff_type->plugin->store(UTEST_LYCTX, diff_type, diff_type_text, strlen(diff_type_text),
-            0, LY_VALUE_XML, NULL, LYD_VALHINT_STRING, NULL, &diff_type_val, NULL, &err);
-    assert_int_equal(LY_SUCCESS, ly_ret);
-    assert_int_equal(LY_ENOT, type->compare(&diff_type_val, &(values[2])));
-    assert_int_equal(LY_ENOT, type->compare(&diff_type_val, &(values[0])));
-    type->free(UTEST_LYCTX, &(diff_type_val));
-
     /* delete values */
     for (unsigned int it = 0; it < sizeof(val_init) / sizeof(val_init[0]); it++) {
         type->free(UTEST_LYCTX, &(values[it]));
diff --git a/tests/utests/types/string.c b/tests/utests/types/string.c
index 68c1d0a..ce5ae8d 100644
--- a/tests/utests/types/string.c
+++ b/tests/utests/types/string.c
@@ -1252,26 +1252,6 @@
     assert_int_equal(LY_ENOT, type->compare(&diff_type_val, &(values[1])));
     type->free(UTEST_LYCTX, &(diff_type_val));
 
-    /* original type  */
-    diff_type_text = "hi";
-    diff_type = ((struct lysc_node_leaf *) mod->compiled->data->next->next)->type;
-    ly_ret = diff_type->plugin->store(UTEST_LYCTX, diff_type, diff_type_text, strlen(diff_type_text),
-            0, LY_VALUE_XML, NULL, LYD_VALHINT_STRING, NULL, &diff_type_val, NULL, &err);
-    assert_int_equal(LY_SUCCESS, ly_ret);
-    assert_int_equal(LY_ENOT, type->compare(&diff_type_val, &(values[0])));
-    assert_int_equal(LY_ENOT, type->compare(&diff_type_val, &(values[1])));
-    type->free(UTEST_LYCTX, &(diff_type_val));
-
-    /* different type (UINT8) */
-    diff_type_text = "20";
-    diff_type = ((struct lysc_node_leaf *) mod->compiled->data->next->next->next)->type;
-    ly_ret = diff_type->plugin->store(UTEST_LYCTX, diff_type, diff_type_text, strlen(diff_type_text),
-            0, LY_VALUE_XML, NULL, LYD_VALHINT_DECNUM, NULL, &diff_type_val, NULL, &err);
-    assert_int_equal(LY_SUCCESS, ly_ret);
-    assert_int_equal(LY_ENOT, type->compare(&diff_type_val, &(values[0])));
-    assert_int_equal(LY_ENOT, type->compare(&diff_type_val, &(values[1])));
-    type->free(UTEST_LYCTX, &(diff_type_val));
-
     /* delete values */
     for (int unsigned it = 0; it < sizeof(val_init) / sizeof(val_init[0]); it++) {
         type->free(UTEST_LYCTX, &(values[it]));