@Contract("null, _ -> false")
  public static boolean statementBreaksLoop(PsiStatement statement, PsiLoopStatement loop) {
    if(statement instanceof PsiBreakStatement breakStatement) {
      return breakStatement.findExitedStatement() == loop;
    }
    if(statement instanceof PsiReturnStatement returnStatement) {
      PsiExpression returnValue = returnStatement.getReturnValue();
      PsiElement cur = loop;
      for(PsiElement parent = cur.getParent();;parent = cur.getParent()) {
        if(parent instanceof PsiLabeledStatement) {
          cur = parent;
        } else if(parent instanceof PsiCodeBlock block) {
          PsiStatement[] statements = block.getStatements();
          if(block.getParent() instanceof PsiBlockStatement && statements.length > 0 && statements[statements.length-1] == cur) {
            cur = block.getParent();
          } else break;
        } else if(parent instanceof PsiIfStatement ifStatement) {
          if(cur == ifStatement.getThenBranch() || cur == ifStatement.getElseBranch()) {
            cur = parent;
          } else break;
        } else break;
      }
      PsiElement nextElement = PsiTreeUtil.skipWhitespacesAndCommentsForward(cur);
      if(nextElement instanceof PsiReturnStatement nextReturn) {
        return EquivalenceChecker.getCanonicalPsiEquivalence()
          .expressionsAreEquivalent(returnValue, nextReturn.getReturnValue());
      }
      return returnValue == null &&
             cur.getParent() instanceof PsiCodeBlock block &&
             block.getParent() instanceof PsiMethod &&
             PsiUtil.isJavaToken(nextElement, JavaTokenType.RBRACE);
    }
    return false;
  }
@Contract("null, _ -> false")
  public static boolean statementBreaksLoop(PsiStatement statement, PsiLoopStatement loop)