Index: /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js	(revision 2990)
+++ /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js	(revision 2991)
@@ -1027,5 +1027,5 @@
 
 	// Tool function used to add an item into an array.
-	var addById = function( array, newItem, nextSiblingId )
+	var addById = function( array, newItem, nextSiblingId, recurse, nullIfNotFound )
 	{
 		if ( nextSiblingId )
@@ -1038,5 +1038,15 @@
 					return newItem;
 				}
-			}
+
+				if ( recurse && item[ recurse ] )
+				{
+					var retval = addById( item[ recurse ], newItem, nextSiblingId, recurse, true );
+					if ( retval )
+						return retval;
+				}
+			}
+
+			if ( nullIfNotFound )
+				return null;
 		}
 
@@ -1046,10 +1056,16 @@
 
 	// Tool function used to remove an item from an array based on its id.
-	removeById = function( array, id )
-	{
-		for ( var i = 0 ; i < array.length ; i++ )
-		{
-			if ( array[ i ].id == id )
+	removeById = function( array, id, recurse )
+	{
+		for ( var i = 0, item ; ( item = array[ i ] ) ; i++ )
+		{
+			if ( item.id == id )
 				return array.splice( i, 1 );
+			if ( recurse && item[ recurse ] )
+			{
+				var retval = removeById( item[ recurse ], id, recurse );
+				if ( retval )
+					return retval;
+			}
 		}
 		return null;
@@ -1214,5 +1230,5 @@
 		add : function( elementDefinition, nextSiblingId )
 		{
-			return addById( this.elements, elementDefinition, nextSiblingId );
+			return addById( this.elements, elementDefinition, nextSiblingId, 'children' );
 		},
 
@@ -1227,5 +1243,5 @@
 		remove : function( id )
 		{
-			removeById( this.elements, id );
+			removeById( this.elements, id, 'children' );
 		}
 	};
