Couldn't you write this as

    if (getRealType(newObj) !== getRealType(prevObj)) {
        prevObj = newObj;
        redoObjLayout(newObj);
        return;
    }
    
    ...