Here we can optimize things as follows. We need to issue `lhs.opEquals(rhs)` anyway so let's hoist it first:

```D
if (!lhs.opEquals(rhs)) return false;
if (typeid(lhs) is typeid(rhs) || typeid(lhs).opEquals(typeid(rhs))) return true;
return rhs.opEquals(lhs);
```

I'm a fan of reducing such code to one expression:

```D
return lhs.opEquals(rhs)
    && (typeid(lhs) is typeid(rhs) || typeid(lhs).opEquals(typeid(rhs)) || rhs.opEquals(lhs));
```

which reads nicely and makes a lot of sense.