              (get-links-from-ul menu-container-el)
              feeds
              documents)
-            (ui/remove-dialog)))))
-    (do
-      (when (classes/has parent-el "new-node")
-        (dom/removeNode parent-el))
-      (ui/remove-dialog))))
+            (ui/remove-dialog))))
+      (do
+        (when (and (not (pos? (count (util/get-children active-el))))
+                   (not (= (.-id active-el) "menu-container")))
+          (dom/removeNode active-el))
+        (ui/remove-dialog)))))
 
 (defn update-related-pages [related-pages]
   (when (not-empty related-pages)

                               (.-target evt)))
                             evt))))

(defn menu-container-el? [el]
  (= (.-id el) "menu-container"))

(defn make-menu-builder-sortable [feeds documents]
  (let [menu-container-el (dom/getElement "menu-container")]
    (ui/to-sortable-tree (dom/getElement menu-container-el)

                       (get-related-images
                        (dom/getElement "related-images-container")))}))


(defn handle-successful-save []
  (let [save-button-el (dom/getElement "save-document")]
    ;; TODO: display status message
    (set! (.-innerHTML save-button-el) "Save")
    (set! (.-disabled save-button-el) false)))

(defn save-new-document-xhr-callback [e]
  (let [xhr (.-target e)]
    (if (= (.getStatus xhr e) 201)
