@NotNull
  static Function<PsiReference, InlineTransformer> getSuitableTransformer(PsiMethod method) {
    PsiReturnStatement[] returns = PsiUtil.findReturnStatements(method);
    PsiCodeBlock body = Objects.requireNonNull(method.getBody());
    if (!InlineMethodProcessor.checkBadReturns(returns, body)) {
      return ref -> {
        InlineUtil.TailCallType type = InlineUtil.getTailCallType(ref);
        if (type == InlineUtil.TailCallType.Return || type == InlineUtil.TailCallType.Simple) {
          return type.getTransformer();
        }
        return new NormalTransformer();
      };
    }
    boolean canUseContinue = Arrays.stream(returns).allMatch(statement -> {
      // We cannot use "continue" without introducing a label if any of returns is inside nested loop.
      // Introducing a label is ugly, so let's move to fallback transformer 
      return PsiTreeUtil.getParentOfType(statement, PsiLoopStatement.class, true, PsiMethod.class) == null;
    });
    BooleanReturnModel model = BooleanReturnModel.from(body, returns);
    return ref -> {
      InlineUtil.TailCallType type = InlineUtil.getTailCallType(ref);
      if (type == InlineUtil.TailCallType.Continue && !canUseContinue) {
        type = InlineUtil.TailCallType.None;
      }
      InlineTransformer fromTailCall = type.getTransformer();
      if (fromTailCall != null) {
        return fromTailCall;
      }
      if (model != null) {
        InlineTransformer fromBooleanModel = model.getTransformer(ref);
        if (fromBooleanModel != null) {
          return fromBooleanModel;
        }
      }
      return new ConvertToSingleReturnTransformer();
    };
  }
@NotNull
  static Function<PsiReference, InlineTransformer> getSuitableTransformer(PsiMethod method)