private static boolean isFlagSetChain(@NotNull PsiExpression expression, boolean isAnd) {
    PsiLocalVariable local = ExpressionUtils.resolveLocalVariable(expression);
    if (local == null) return false;
    PsiExpression initializer = local.getInitializer();
    if (!ExpressionUtils.isLiteral(initializer, isAnd)) return false;
    if (!(PsiUtil.getVariableCodeBlock(local, null) instanceof PsiCodeBlock block)) return false;
    PsiElement[] defs = DefUseUtil.getDefs(block, local, expression.getParent());
    // boolean x = false; x|=something;
    return defs.length == 1 && defs[0] == local && 
           VariableAccessUtils.getVariableReferences(local).stream().filter(PsiUtil::isAccessedForWriting).limit(2).count() > 1;
  }
private static boolean isFlagSetChain(@NotNull PsiExpression expression, boolean isAnd)