def METHOD_NAME(self, test):
    case_structures = []
    indices = {case: [] for case in self.get_all_case_names(test)}
    for i, subcase in enumerate(test.get('subcases', [])):
        indices[subcase[0]].append(CaseIndex(
            related_structure=CaseStructure(
                attrs={
                    'create': False,
                    'owner_id': self.user.user_id if subcase[1] in test.get('owned', []) else uuid.uuid4().hex,
                    'close': subcase[1] in test.get('closed', []),
                },
                case_id=subcase[1],
            ),
            relationship='child',
            identifier='child_{}'.format(i),
        ))
    for i, extension in enumerate(test.get('extensions', [])):
        indices[extension[0]].append(CaseIndex(
            related_structure=CaseStructure(
                attrs={
                    'create': False,
                    'owner_id': (self.user.user_id if extension[1]
                                 in test.get('owned', []) else uuid.uuid4().hex),
                    'close': extension[1] in test.get('closed', []),
                },
                case_id=extension[1],
            ),
            relationship='extension',
            identifier='extension_{}'.format(i),
        ))
    for case in self.get_all_case_names(test):
        case_structures.append(CaseStructure(
            attrs={
                'create': True,
                'owner_id': self.user.user_id if case in test.get('owned', []) else uuid.uuid4().hex,
                'close': case in test.get('closed', []),
            },
            case_id=case,
            indices=indices[case],
        ))
    self.device.post_changes(case_structures)