private static Document serializeHelper(Object object,Document doc, Map<Object, String> table )throws Exception{
		String id = Integer.toString(table.size());
		table.put(object, id);
		Class<? extends Object> objClass = object.getClass();
		Element eleObj = new Element("Object");
		String objName = objClass.getName();
		eleObj.setAttribute( "Class", objName);
		eleObj.setAttribute( "ID", id );
		doc.getRootElement().addContent(eleObj);
		if (!objClass.isArray()) {
			Field[] fields = objClass.getDeclaredFields();
			for (int i=0; i<fields.length; i++) {
				if ( !Modifier.isPublic(fields[i].getModifiers()) )
					fields[i].setAccessible(true);
					 
				Element eleField = new Element("Field");
				eleField.setAttribute("Name", fields[i].getName() );
				Class<?> decClass = fields[i].getDeclaringClass();
				eleField.setAttribute("DeclaringClass", decClass.getName());
					 
				Class<?> fieldtype = fields[i].getType();
				Object child = fields[i].get(object);
				
				if (Modifier.isTransient(fields[i].getModifiers())){
					child = null;
				}
				eleField.addContent(serializeVariable(fieldtype, child,doc, table));	 
				eleObj.addContent(eleField);
			}
		}
		else {
			Class<?> componentType = objClass.getComponentType();
			int length = Array.getLength(object);
			eleObj.setAttribute("Length", Integer.toString(length));
			for (int i=0; i<length; i++) {
				eleObj.addContent(serializeVariable(componentType,Array.get(object,i),doc,table));
			}
		}
	return doc;
	}