Maybe shorter:
```php
			if (isset($checked[$expected])) {
				return $checked[$expected] === $actual;
			} elseif (isset($checked[$actual])) {
				return FALSE;
			} elseif ($expected === $actual) {
				return TRUE;
			}
```
Btw. second `elseif` seems logically, but test passes without it too. It just returns FALSE on next level.