+ if deep == false then
+ deep = nil
+ end
+
+ local _, child
+ for _, child in ipairs(children) do
+ sub_path[#prefix+1] = child.name
+
+ local res_path = _find_eligible_node(child.node, sub_path,
+ deep, types, true)
+
+ if res_path then
+ return res_path
+ end
+ end
+ end
+
+ if descend and
+ (not types or
+ (type(root.target) == "table" and
+ util.contains(types, root.target.type)))
+ then
+ return prefix
+ end
+end
+
+function _find_node(recurse, types)
+ local path = { unpack(context.path) }
+ local name = table.concat(path, ".")
+ local node = context.treecache[name]
+
+ path = _find_eligible_node(node, path, recurse, types)
+
+ if path then
+ dispatch(path)
+ else
+ require "luci.template".render("empty_node_placeholder")
+ end
+end
+
+function _firstchild()
+ return _find_node(false, nil)