PatternVariableCandidate (@NotNull Statement ifElseStat, @NotNull VarExprent operand, @NotNull ConstExprent checkType, boolean recordPatternSupport, @NotNull Statement topLevelStatement) { if (ifElseStat instanceof BasicBlockStatement basicBlockStatement) { //check that cast correct and get the last assignment PatternVariableCandidate candidate = findSimpleCandidateFromIfStat(ifElseStat, operand, checkType, topLevelStatement); if (candidate == null) return null; //check what if it is record patterns if (recordPatternSupport) { //collect everything from zero to check PatternVariableCandidate recordCandidate = findInitRecordPatternCandidate(basicBlockStatement, operand, candidate.getVarExprent()); if (recordCandidate != null) { recordCandidate.getTempVarAssignments().addAll(candidate.getTempVarAssignments()); return recordCandidate; } } return candidate; } else if (ifElseStat instanceof IfStatement || ifElseStat instanceof SequenceStatement) { return findInitPatternVarCandidate(ifElseStat.getFirst(), operand, checkType, recordPatternSupport, topLevelStatement); } return null; }