plugins REFACTOR clarify plugins compare callback behavior

And modify internal callbacks accordingly.
diff --git a/src/plugins_types.c b/src/plugins_types.c
index bea306e..2d70b8d 100644
--- a/src/plugins_types.c
+++ b/src/plugins_types.c
@@ -248,7 +248,11 @@
 static LY_ERR
 ly_type_compare_simple(const struct lyd_value *val1, const struct lyd_value *val2)
 {
-    if ((val1->realtype == val2->realtype) && (val1->canonical == val2->canonical)) {
+    if (val1->realtype != val2->realtype) {
+        return LY_ENOT;
+    }
+
+    if (val1->canonical == val2->canonical) {
         return LY_SUCCESS;
     }
 
@@ -1366,8 +1370,12 @@
  * Implementation of the ly_type_compare_clb.
  */
 static LY_ERR
-ly_type_compare_empty(const struct lyd_value *UNUSED(val1), const struct lyd_value *UNUSED(val2))
+ly_type_compare_empty(const struct lyd_value *val1, const struct lyd_value *val2)
 {
+    if (val1->realtype != val2->realtype) {
+        return LY_ENOT;
+    }
+
     /* empty has just one value, so empty data must be always the same */
     return LY_SUCCESS;
 }
@@ -1539,6 +1547,10 @@
 static LY_ERR
 ly_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;
     }
@@ -1710,6 +1722,10 @@
 {
     LY_ARRAY_COUNT_TYPE u, v;
 
+    if (val1->realtype != val2->realtype) {
+        return LY_ENOT;
+    }
+
     if (val1 == val2) {
         return LY_SUCCESS;
     } else if (!val1->target || !val2->target || (LY_ARRAY_COUNT(val1->target) != LY_ARRAY_COUNT(val2->target))) {
@@ -2249,6 +2265,10 @@
 static LY_ERR
 ly_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/src/plugins_types.h b/src/plugins_types.h
index 7c43767..d8ebec2 100644
--- a/src/plugins_types.h
+++ b/src/plugins_types.h
@@ -227,7 +227,7 @@
 /**
  * @brief Callback for comparing 2 values of the same type.
  *
- * Caller is responsible to provide values of the SAME type.
+ * In case the value types (::lyd_value.realtype) are different, ::LY_ENOT must always be returned.
  *
  * @param[in] val1 First value to compare.
  * @param[in] val2 Second value to compare.
diff --git a/src/tree_data.c b/src/tree_data.c
index c7532b3..95af572 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -2473,10 +2473,6 @@
 
             term1 = (struct lyd_node_term *)node1;
             term2 = (struct lyd_node_term *)node2;
-            if (term1->value.realtype != term2->value.realtype) {
-                return LY_ENOT;
-            }
-
             return term1->value.realtype->plugin->compare(&term1->value, &term2->value);
         case LYS_CONTAINER:
             if (options & LYD_COMPARE_DEFAULTS) {
@@ -2604,10 +2600,6 @@
         return LY_ENOT;
     }
 
-    if (meta1->value.realtype != meta2->value.realtype) {
-        return LY_ENOT;
-    }
-
     return meta1->value.realtype->plugin->compare(&meta1->value, &meta2->value);
 }