fix duplicate type check and don't try to recurse into null
fix duplicate type check and don't try to recurse into null