         } else {
             if let customRelationshipName = relationship.customKey {
                 if customRelationshipName.contains(".") {
-                    if let deepMappingRootKey = customRelationshipName.components(separatedBy: ".").first {
-                        if let rootObject = dictionary[deepMappingRootKey] as? [String: Any] {
-                            if let deepMappingLeaveKey = customRelationshipName.components(separatedBy: ".").last {
-                                children = rootObject[deepMappingLeaveKey] as? [[String: Any]]
-                            }
-                        }
+                    var rootObject: [String: Any]? = dictionary
+                    let deepMappingKeys = customRelationshipName.split(separator: ".").map { String($0)}
+                    let keyComponents = deepMappingKeys[0...deepMappingKeys.count - 2]
+    
+                    for key in keyComponents {
+                        rootObject = rootObject?[key] as? [String: Any]
+                    }
+                    
+                    if let innerObject = rootObject, let deepMappingLeaveKey = deepMappingKeys.last {
+                        children = innerObject[deepMappingLeaveKey] as? [[String: Any]]
                     }
                 } else {
                     children = dictionary[customRelationshipName] as? [[String: Any]]


                var child: Any?
                if keyName.contains(".") {
                    if let deepMappingRootkey = keyName.components(separatedBy: ".").first {
                        if let rootObject = dictionary[deepMappingRootkey] as? [String: Any] {
                            if let deepMappingLeaveKey = keyName.components(separatedBy: ".").last {
                                child = rootObject[deepMappingLeaveKey]
                            }
                        }
                    }
                } else {
                    child = dictionary[keyName]

            if relationship.isToMany {
                var children: Any?
                if keyName.contains(".") {
                    var rootObject: [String: Any]? = dictionary
                    let deepMappingKeys = keyName.split(separator: ".").map { String($0)}
                    let keyComponents = deepMappingKeys[0...deepMappingKeys.count - 2]
                    
                    for key in keyComponents {
                        rootObject = rootObject?[key] as? [String: Any]
                    }
                    
                    if let innerObject = rootObject, let deepMappingLeaveKey = deepMappingKeys.last {
                        children = innerObject[deepMappingLeaveKey]
                    }
                } else {
                    children = dictionary[keyName]
