     
     // MARK: - Helpers
     
-    private func allNonDividerSubviews() -> [NSView] {
-        // Some pane views can be splitviews themselves, if horizontal|vertical split has been
-        // embedded inside a vertical|horizontal pane.
-        return self.subviews.filter({ $0.isKindOfClass(PaneView) || $0.isKindOfClass(PressureSplitView) })
-    }
-    
-    private func allSubPaneViews() -> [PaneView] {
-        return self.subviews.filter({ $0.isKindOfClass(PaneView) }) as! [PaneView]
-    }
-    
-    private func lastSubPaneView() -> PaneView {
-        return self.allSubPaneViews().sort({ (first, second) -> Bool in
+    // Consider both PaneViews and PressureSplitViews (to also count perpendicular splits).
+    private func paneSubviews() -> [PaneView] {
+        return self.subviews.filter({ $0.isKindOfClass(PaneView) }).sort({ (first, second) -> Bool in
             return (self.vertical) ?
                 (CGRectGetMaxX(first.frame) < CGRectGetMaxX(second.frame)) :
                 (CGRectGetMaxY(first.frame) < CGRectGetMaxY(second.frame))
-        }).last!
-    }
-    
-    private func indexOfPaneView(paneView: PaneView) -> Int {
-        let sortedSubviews = self.allNonDividerSubviews().sort( { (firstView, secondView) -> Bool in
-            let v1 = (self.vertical) ? CGRectGetMinX(firstView.frame) : CGRectGetMinY(firstView.frame)
-            let v2 = (self.vertical) ? CGRectGetMinX(secondView.frame) : CGRectGetMinY(secondView.frame)
-            return v1 < v2
-        })
-        return sortedSubviews.indexOf(paneView)!
+        }) as! [PaneView]
+    }
+    
+    private func lastPaneSubview() -> PaneView? {
+        return self.paneSubviews().last
+    }
+    
+    private func indexOfPaneView(paneView: PaneView) -> Int? {
+        return self.paneSubviews().indexOf(paneView)
     }
 }
 

    }
    
    private func remove(paneView pane: PaneView) {
        let parentSplitView = pane.parentSplitView()
        if parentSplitView?.allSubPaneViews().count == 1 {
            parentSplitView?.removeFromSuperview()
        }
        else {
            pane.removeFromSuperview()
        }
    }
    
    func split(paneView pane: PaneView) {
        let mask = self.window?.styleMask;
        if (mask ==  NSFullScreenWindowMask || mask == NSFullSizeContentViewWindowMask) {
            NSBeep();

        return false
    }
    
    override public func viewDidMoveToWindow() {
        super.viewDidMoveToWindow()
        if (self.selectedPaneView == nil) {
            self.select(paneView: self.lastPaneSubview())
        }
    }
    
    // MARK: - Selection

    override public func mouseUp(theEvent: NSEvent) {
        let downPoint = self.convertPoint(theEvent.locationInWindow, fromView:nil)
        let clickedSubviews = self.paneSubviews().filter({ NSPointInRect(downPoint, $0.frame) })
        if clickedSubviews.count == 1 && clickedSubviews.first!.isKindOfClass(PaneView) {
            self.select(paneView: clickedSubviews.first! as PaneView)
        }
        super.mouseUp(theEvent)
    }
    
    private func select(paneView pane: PaneView?) {
        self.selectedPaneView = pane
        for paneSubview in self.paneSubviews() {
            paneSubview.select(paneSubview == pane)
        }
        if pane != nil {
            self.window?.makeFirstResponder(pane)
        }
    }
    
    // MARK: - Adding & Removing Subviews

    private func pressure(vertically: Bool) -> Int {
        return (vertically == self.vertical) ? max(self.subviews.count, 1) : 1
    }
    
    private func minimumExtent(vertically: Bool) -> CGFloat {
        guard self.delegate != nil, let delegate = self.delegate as! PressureSplitViewDelegate? else {
            return 1
        }
        return (vertically == true) ? delegate.minimumWidth : delegate.minimumHeight
    }
    
    private func currentExtent(vertically: Bool) -> CGFloat {
        return (vertically == true) ? CGRectGetWidth(self.frame) : CGRectGetHeight(self.frame);
    }
    
    private func maximumScreenRect() -> NSRect {
        return self.window!.contentRectForFrameRect(self.window!.screen!.frame)
    }
    
    private func maximumExtent(vertically: Bool) -> CGFloat {
        let rect = self.maximumScreenRect()
        return (self.vertical) ? CGRectGetWidth(rect) : CGRectGetHeight(rect)
    }
    
    // MARK: - Close

    public func close(paneView pane: PaneView) -> Void {
        if self.paneSubviews().count == 1 {
            let alert = NSAlert()
            alert.alertStyle = .WarningAlertStyle
            alert.messageText = NSLocalizedString("Be careful!", comment: "")
