private static PsiElement @NotNull [] extractReferencedVariables(@NotNull PsiTypeElement typeElement) {
    final PsiElement parent = typeElement.getParent();
    if (parent instanceof PsiVariable) {
      if (parent instanceof PsiField aField) {
        List<PsiField> fields = new ArrayList<>();
        while (true) {
          fields.add(aField);
          aField = PsiTreeUtil.getNextSiblingOfType(aField, PsiField.class);
          if (aField == null || aField.getTypeElement() != typeElement) {
            return fields.toArray(PsiElement.EMPTY_ARRAY);
          }
        }
      }
      else if (parent instanceof PsiLocalVariable) {
        final PsiDeclarationStatement declaration = PsiTreeUtil.getParentOfType(parent, PsiDeclarationStatement.class);
        if (declaration != null) {
          return Arrays.stream(declaration.getDeclaredElements()).filter(PsiVariable.class::isInstance).toArray(PsiVariable[]::new);
        }
      }
      return new PsiElement[]{parent};
    } else {
      return PsiElement.EMPTY_ARRAY;
    }
  }
private static PsiElement @NotNull [] extractReferencedVariables(@NotNull PsiTypeElement typeElement)