@SuppressWarnings("unchecked")
    private Object delete(DatabaseUpdater updater, Object object) throws UpdateException {

        if(object == null){
            //No entity to delete here, so abort this step.
            return object;
        }
        
        for (ExtendedField field : DaoUtils.getAllMappingsWithSuperclasses(object.getClass())) {

            if (field.isCascadingDelete()) {
                MergeMapping mapping = new MergeMapping(object, field);

                if (mapping.isManyToMany() || mapping.isManyToOne()) {
                    clearReferences(updater, mapping);

                    for (Object subObject : (List<Object>) field.getValue(object)) {
                        mapping.setObjectTo(subObject);
                        delete(updater, subObject);
                    }
                } else {
                    Object subObject = field.getValue(object);
                    delete(updater, subObject);
                }
            }
        }

        deleteSingle(updater, object);

        return object;
    }