         case let .DictionaryItem(dictionary):
             return dictionary.elementAtIndex(index).key
         default:
-            return nil
-        }
-    }
-
-
+            assert(false, "Impossible state: all nodes must be the root node or the child of a dictionary/array")
+        }
+    }
+
+
+    /// Sets the key for the specified tree node. Due to the implementation of other data source
+    /// methods, the tree node can be assumed to have a dictionary item as its parent. 
+    ///
+    /// This method works by getting the parent of the specified tree node, getting its
+    /// (dictionary) item, and editing it by replacing the tree node’s corresponding key with
+    /// the new key. The parent node’s (dictionary) item is then replaced with the edited
+    /// version using `‑setItem:ofTreeNodeAtIndexPath:nodeOperation:`. That method handles
+    /// making actual model changes and registering an appropriate undo action.
+    ///
+    /// - parameter key: The key being set. If the dictionary already contains this key, has no
+    ///       effect. This should not be possible because of our implementation of 
+    //        `control:textShouldEndEditing:`.
+    /// - parameter treeNode: The tree node whose key is being set.
     private func setKey(key: String, ofTreeNode treeNode: PropertyListTreeNode) {
         guard let parentNode = treeNode.parentNode, index = treeNode.index else {
             return

    }
    

    private func setValue(newValue: PropertyListItem, ofTreeNode treeNode: PropertyListTreeNode, needsChildRegeneration: Bool = false) {
        guard let parentNode = treeNode.parentNode else {
            let nodeOperation: TreeNodeOperation? = needsChildRegeneration ? .RegenerateChildren : nil

// MARK: - Property List Type Pop-Up Menu

private extension PropertyListType {
    /// Returns the `PropertyListType` instance that corresponds to the specified index of the
    /// type pop-up menu, or `nil` if the index doesn’t have a known type correspondence.
    /// - parameter index: The index of the type pop-up menu whose type is being returned.
    init?(typePopUpMenuItemIndex index: Int) {
        switch index {
        case 0:
