 
         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 {
-                            filteredObjectDictionary = rootObject[deepMappingLeaveKey] as? [String: Any]
-                            jsonContainsRelationship = rootObject[deepMappingLeaveKey] != nil
-                        }
-                    }
+                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 {
+                    filteredObjectDictionary = innerObject[deepMappingLeaveKey] as? [String: Any]
+                    jsonContainsRelationship = innerObject[deepMappingLeaveKey] != nil
                 }
             } else {
                 filteredObjectDictionary = dictionary[customRelationshipName] as? [String: Any]

        } 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]]
                            }
                        }
                    }
                } else {
                    children = dictionary[customRelationshipName] as? [[String: Any]]


                var child: 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 {
                        child = innerObject[deepMappingLeaveKey]
                    }
                } else {
                    child = dictionary[keyName]
