dm: core: Add a function to create an empty tree

Provide a function to create a new, empty tree.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index 3bf9776..594116e 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -1346,3 +1346,19 @@
 	return 0;
 }
 DM_TEST(dm_test_livetree_ensure, UT_TESTF_SCAN_FDT);
+
+static int dm_test_oftree_new(struct unit_test_state *uts)
+{
+	ofnode node, subnode, check;
+	oftree tree;
+
+	ut_assertok(oftree_new(&tree));
+	node = oftree_root(tree);
+	ut_assert(ofnode_valid(node));
+	ut_assertok(ofnode_add_subnode(node, "edmund", &subnode));
+	check = ofnode_find_subnode(node, "edmund");
+	ut_asserteq(check.of_offset, subnode.of_offset);
+
+	return 0;
+}
+DM_TEST(dm_test_oftree_new, UT_TESTF_SCAN_FDT);