@Nullable
  private static PsiElement findElementToParenthesise(@NotNull PsiElement nodeAtCaret) {
    PsiElement wrappable = nodeAtCaret;

    while (true) {
      PsiElement next = PsiTreeUtil.getParentOfType(wrappable, PyEditorHandlerConfig.CLASSES_TO_PARENTHESISE_ON_ENTER);
      if (next == null) {
        break;
      }
      wrappable = next;
    }

    return wrappable != nodeAtCaret ? wrappable : null;
  }
@Nullable
  private static PsiElement findElementToParenthesise(@NotNull PsiElement nodeAtCaret)