static IDictionary<string, object> Serialize(Animation animation)
{
if(animation == null)
throw new ArgumentNullException("animation");
// Create the representation
var obj = new Dictionary<string, object>();
obj["AnimationName"] = animation.Name;
// Add the properties
foreach(var pair in animation.Properties)
obj[pair.Key] = pair.Value;
// Recursively add the children
var children = new List<IDictionary<string, object>>();
foreach(var child in animation.Children)
children.Add(Serialize(child));
obj["AnimationChildren"] = children.ToArray();
return obj;
}