It would be better to check if $value instanceof Route. I guess this is what is expected by `$value->getPath()`.