private function filter($items, $path, $type)
{
if (!$items) {
return null;
}
return array_filter($items, function ($item) use($path, $type) {
$itemCopy = $item;
// key into the value with the given path
foreach ($path as $key) {
$itemCopy = $itemCopy[$key];
}
if (strtolower($itemCopy) === strtolower($type)) {
return $item;
}
});
}