The use of `instanceof` might be a code smell and I am in front of the following code which seems ok. Would you consider that `instanceof` should not be used in such case? What would be the pattern to use?

```php
<?php

interface Account {}

class PrivateAccount implements Account {}

class PublicAccount implements Account {}

class User {
    private $publicAccounts;
    private $privateAccounts;

    public function hasAccount(Account $account) {
        $haystack = [];

        if($account instanceof PrivateAccount) {
            $haystack = $this->privateAccounts;
        } else if($account instanceof PublicAccount) {
            $haystack = $this->publicAccounts;
        }

        foreach($haystack as $someAccount) {
            if($account->getId() == $someAccount->getId()) {
                return true;
            }
        }
        return false;
    }
}

```

To be more specific, `$privateAccounts` and `$publicAccounts` are objects that will be lazy loaded by an ORM from a relationnal database, so calling `getId()` is costly (each call results in a database request). PublicAccount and PrivateAccount are 2 tables from the database.

Using `$haystack = array_merge($privateAccounts, $publicAccounts)` would remove the use of `instanceof` but would have a performance cost.