private static void collectPatternVariableCandidates(@NotNull PsiPattern pattern,
                                                       @NotNull PsiExpression scope,
                                                       @Nullable Pair<PsiPatternVariable, PsiRecordComponent> parent,
                                                       Collection<PatternVariableWrapper> candidates,
                                                       boolean strict) {
    if (pattern instanceof PsiTypeTestPattern) {
      PsiPatternVariable variable = ((PsiTypeTestPattern)pattern).getPatternVariable();
      if (variable != null && !PsiTreeUtil.isAncestor(scope, variable.getDeclarationScope(), strict)) {
        if (parent == null) {
          candidates.add(new PatternVariableWrapper(variable, false));
        }
        else {
          candidates.add(new DestructionComponent(variable, parent.getFirst(), parent.getSecond(), false));
        }
      }
    }
    else if (pattern instanceof PsiDeconstructionPattern) {
      PsiDeconstructionPattern deconstruction = (PsiDeconstructionPattern)pattern;
      PsiTypeElement typeElement = deconstruction.getTypeElement();
      PsiType type = typeElement.getType();
      PsiClass aClass = PsiUtil.resolveClassInClassTypeOnly(type);
      PsiPatternVariable variable = deconstruction.getPatternVariable();
      boolean isFake = variable == null;
      if (aClass != null) {
        PsiRecordComponent[] recordComponents = aClass.getRecordComponents();
        PsiPattern[] components = deconstruction.getDeconstructionList().getDeconstructionComponents();
        if (recordComponents.length == components.length && recordComponents.length != 0) {
          if (isFake) {
            variable = createFakePatternVariable(pattern, typeElement, type);
          }
          PatternVariableWrapper patternVariableWrapper =
            parent == null
            ? new PatternVariableWrapper(variable, isFake)
            : new DestructionComponent(variable, parent.getFirst(), parent.getSecond(), isFake);
          candidates.add(patternVariableWrapper);
          for (int i = 0; i < components.length; i++) {
            collectPatternVariableCandidates(components[i], scope, Pair.pair(variable, recordComponents[i]), candidates, strict);
          }
        }
      }
    }
  }
private static void collectPatternVariableCandidates(@NotNull PsiPattern pattern,
                                                       @NotNull PsiExpression scope,
                                                       @Nullable Pair<PsiPatternVariable, PsiRecordComponent> parent,
                                                       Collection<PatternVariableWrapper> candidates,
                                                       boolean strict)