Explain a non-obvious check in portal teleportation code.