Why not returning early?
`if ($type !== null) { return false; }` 
That would resolve the multidepth here.