parser BUGFIX memory-leak due to tpdfs_nodes
diff --git a/src/tree_schema_free.c b/src/tree_schema_free.c
index 6d31a75..234daf8 100644
--- a/src/tree_schema_free.c
+++ b/src/tree_schema_free.c
@@ -1134,6 +1134,10 @@
 yang_parser_ctx_free(struct lys_yang_parser_ctx *ctx)
 {
     if (ctx) {
+        if (ctx->main_ctx == (struct lys_parser_ctx *)ctx) {
+            ly_set_erase(&ctx->tpdfs_nodes, NULL);
+            ly_set_erase(&ctx->grps_nodes, NULL);
+        }
         free(ctx);
     }
 }
@@ -1142,6 +1146,10 @@
 yin_parser_ctx_free(struct lys_yin_parser_ctx *ctx)
 {
     if (ctx) {
+        if (ctx->main_ctx == (struct lys_parser_ctx *)ctx) {
+            ly_set_erase(&ctx->tpdfs_nodes, NULL);
+            ly_set_erase(&ctx->grps_nodes, NULL);
+        }
         lyxml_ctx_free(ctx->xmlctx);
         free(ctx);
     }