Consistently compare path entities with undef and incompatible classes.