private static JetDelegatorToSuperCall findSuperCall(
      BindingContext bindingContext, JetElement classOrObject) {
    if (!(classOrObject instanceof JetClassOrObject)) {
      return null;
    }

    if (classOrObject instanceof JetClass && ((JetClass) classOrObject).isTrait()) {
      return null;
    }
    for (JetDelegationSpecifier specifier :
        ((JetClassOrObject) classOrObject).getDelegationSpecifiers()) {
      if (specifier instanceof JetDelegatorToSuperCall) {
        JetType superType = bindingContext.get(TYPE, specifier.getTypeReference());
        assert superType != null;
        ClassDescriptor superClassDescriptor =
            (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
        assert superClassDescriptor != null;
        if (!isInterface(superClassDescriptor)) {
          return (JetDelegatorToSuperCall) specifier;
        }
      }
    }

    return null;
  }
  public static void reportCyclicInheritanceHierarchyError(
      @NotNull BindingTrace trace,
      @NotNull ClassDescriptor classDescriptor,
      @NotNull ClassDescriptor superclass) {
    PsiElement psiElement =
        BindingContextUtils.classDescriptorToDeclaration(
            trace.getBindingContext(), classDescriptor);

    PsiElement elementToMark = null;
    if (psiElement instanceof JetClassOrObject) {
      JetClassOrObject classOrObject = (JetClassOrObject) psiElement;
      for (JetDelegationSpecifier delegationSpecifier : classOrObject.getDelegationSpecifiers()) {
        JetTypeReference typeReference = delegationSpecifier.getTypeReference();
        if (typeReference == null) continue;
        JetType supertype = trace.get(TYPE, typeReference);
        if (supertype != null && supertype.getConstructor() == superclass.getTypeConstructor()) {
          elementToMark = typeReference;
        }
      }
    }
    if (elementToMark == null && psiElement instanceof PsiNameIdentifierOwner) {
      PsiNameIdentifierOwner namedElement = (PsiNameIdentifierOwner) psiElement;
      PsiElement nameIdentifier = namedElement.getNameIdentifier();
      if (nameIdentifier != null) {
        elementToMark = nameIdentifier;
      }
    }
    if (elementToMark != null) {
      trace.report(CYCLIC_INHERITANCE_HIERARCHY.on(elementToMark));
    }
  }