https://github.com/bitcoin/bitcoin/blob/9ad6f14175c19b5d47267c3dd5840c14bad43c83/src/validation.cpp#L3711

If i'm following right the flow of the code, when we hit this lane `pindex` should be always equal to nullptr thus this check may be omitted
tip = tip->pprev;
        }
        
        LimitValidationInterfaceQueue();
        
        if (!FlushStateToDisk(params, state, FlushStateMode::PERIODIC)) {
            LogPrintf("RewindBlockIndex: unable to flush state to disk (%s)\n", state.ToString());
            return false;
        }
    }
    {
        LOCK(cs_main);
        if (m_chain.Tip() != nullptr) {
            
            
            PruneBlockIndexCandidates();
            CheckBlockIndex(params.GetConsensus());
            
            
            
            BlockValidationState state;
            if (!FlushStateToDisk(params, state, FlushStateMode::ALWAYS)) {
                LogPrintf("RewindBlockIndex: unable to flush state to disk (%s)\n", state.ToString());
                return false;
            }
        }
    }
    return true;
}
void CChainState::UnloadBlockIndex() {