istype(L) would fail if L is null, so no need to do both checks.