diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h
index 796e3e90..20dab2f3 100644
--- a/include/libcamera/internal/yaml_parser.h
+++ b/include/libcamera/internal/yaml_parser.h
@@ -207,7 +207,11 @@ public:
 
 	const YamlObject &operator[](std::size_t index) const;
 
-	bool contains(std::string_view key) const;
+	bool contains(std::string_view key) const
+	{
+		return find(key);
+	}
+
 	const YamlObject &operator[](std::string_view key) const;
 	const YamlObject *find(std::string_view key) const;
 
diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp
index da8cb61f..72483ef3 100644
--- a/src/libcamera/yaml_parser.cpp
+++ b/src/libcamera/yaml_parser.cpp
@@ -369,10 +369,6 @@ const YamlObject &YamlObject::operator[](std::size_t index) const
  *
  * \return True if an element exists, false otherwise
  */
-bool YamlObject::contains(std::string_view key) const
-{
-	return dictionary_.find(key) != dictionary_.end();
-}
 
 /**
  * \fn YamlObject::operator[](std::string_view key) const
@@ -387,14 +383,8 @@ bool YamlObject::contains(std::string_view key) const
  */
 const YamlObject &YamlObject::operator[](std::string_view key) const
 {
-	if (type_ != Type::Dictionary)
-		return empty;
-
-	auto iter = dictionary_.find(key);
-	if (iter == dictionary_.end())
-		return empty;
-
-	return *iter->second;
+	auto *child = find(key);
+	return child ? *child : empty;
 }
 
 /**
