      -x   → x-times go out of sexps to end
      universal-command interpreted as 0"
     (interactive "P")
-    (condition-case err
-        (let ((arg)
-              (loop))
-          (cond
-           ((null a) ;; back-up once
-            (setq arg -1
-                  loop nil))
-           ((eq a '-) ;; up to end of all sexps
-            (setq arg 1
-                  loop t))
-           ((numberp a)
+    (if (eq major-mode 'org-mode)
+        (if a
+            (while t (org-up-element))
+          (org-up-element))
+      (condition-case err
+          (let ((arg)
+                (loop))
             (cond
-             ((= a 0) ;; back-up to begin of all sexps
+             ((null a) ;; back-up once
               (setq arg -1
+                    loop nil))
+             ((eq a '-) ;; up to end of all sexps
+              (setq arg 1
                     loop t))
-             (t (setq arg (- a) ;; do it a times
-                      loop nil))))
-           (t (setq arg -1 ;; interpret `universal-command'
-                    loop t)))
-          (while (progn  ;; do-while loop
-                   (up-list arg t t)
-                   loop)))
-      (scan-error ;; stay quiet
-       nil)))
+             ((numberp a)
+              (cond
+               ((= a 0) ;; back-up to begin of all sexps
+                (setq arg -1
+                      loop t))
+               (t (setq arg (- a) ;; do it a times
+                        loop nil))))
+             (t (setq arg -1 ;; interpret `universal-command'
+                      loop t)))
+            (while (progn  ;; do-while loop
+                     (up-list arg t t)
+                     loop)))
+        (scan-error ;; stay quiet
+         nil))))
+
   (defun ar/kill-sexp (&optional arg)
     "If inside symbol, kill from position to end of symbol.  With any ARG, kill current sexp."
     (interactive "P")

                 (sp-wrap-with-pair (car pair))))))))

  ;; https://www.reddit.com/r/emacs/comments/dewzuy/weekly_tipstricketc_thread/f3be8kq?utm_source=share&utm_medium=web2x
  (defun ar/backward-up-sexp (a)
    "Backwards up multiple sexps.
   prefix command interpretation:
     0    → to beginning of all nested sexps
     -    → to end of all nested sexps

   ("C-M-p" . sp-backward-sexp)
   ("C-M-a" . sp-beginning-of-sexp)
   ("C-M-e" . sp-end-of-sexp)
   ("C-M-u" . ar/backward-up-sexp-dwim)
   ("C-M-d" . sp-down-sexp)
   ("C-M-t" . sp-transpose-sexp)
   ("M-t t" . sp-transpose-sexp)
