+ const char *next, *slash;
+ int len;
+ struct tree_entry_list *elem = &root_entry;
+
+ /* Find tree element, descending from root, that
+ * corresponds to the named path, lazily expanding
+ * the tree if possible.
+ */
+
+ while (path) {
+ /* The fact we still have path means that the caller
+ * wants us to make sure that elem at this point is a
+ * directory, and possibly descend into it. Even what
+ * is left is just trailing slashes, we loop back to
+ * here, and this call to prepare_children() will
+ * catch elem not being a tree. Nice.
+ */
+ if (prepare_children(elem))
+ return NULL;
+
+ slash = strchr(path, '/');
+ if (!slash) {
+ len = strlen(path);
+ next = NULL;
+ }
+ else {
+ next = slash + 1;
+ len = slash - path;
+ }
+ if (len) {
+ /* (len == 0) if the original path was "drivers/char/"
+ * and we have run already two rounds, having elem
+ * pointing at the drivers/char directory.
+ */
+ elem = elem->item.tree->entries;
+ while (elem) {
+ if ((strlen(elem->name) == len) &&
+ !strncmp(elem->name, path, len)) {
+ /* found */
+ break;
+ }
+ elem = elem->next;
+ }
+ if (!elem)
+ return NULL;