data tree FEATURE function for metadata comparison
diff --git a/src/tree_data.c b/src/tree_data.c
index 8125bb1..9a905ac 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -1945,6 +1945,28 @@
     return LY_EINT;
 }
 
+API LY_ERR
+lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2)
+{
+    if (!meta1 || !meta2) {
+        if (meta1 == meta2) {
+            return LY_SUCCESS;
+        } else {
+            return LY_ENOT;
+        }
+    }
+
+    if ((LYD_NODE_CTX(meta1->parent) != LYD_NODE_CTX(meta2->parent)) || (meta1->annotation != meta2->annotation)) {
+        return LY_ENOT;
+    }
+
+    if (meta1->value.realtype != meta2->value.realtype) {
+        return LY_ENOT;
+    }
+
+    return meta1->value.realtype->plugin->compare(&meta1->value, &meta2->value);
+}
+
 /**
  * @brief Duplicate a single node and connect it into @p parent (if present) or last of @p first siblings.
  *
diff --git a/src/tree_data.h b/src/tree_data.h
index c2ad770..d218490 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -1016,6 +1016,16 @@
 LY_ERR lyd_compare(const struct lyd_node *node1, const struct lyd_node *node2, int options);
 
 /**
+ * @brief Compare 2 metadata.
+ *
+ * @param[in] meta1 First metadata.
+ * @param[in] meta2 Second metadata.
+ * @return LY_SUCCESS if the metadata are equivalent.
+ * @return LY_ENOT if not.
+ */
+LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2);
+
+/**
  * @defgroup dupoptions Data duplication options
  * @ingroup datatree
  *