'Associate all images with parents and children.'

def find_parents(self):

    sort_images = dict()
    for image in self.images:
        sort_images[image.canonical_name] = image
    for (parent_name, parent) in sort_images.items():
        for image in sort_images.values():
            if (image.parent_name == parent_name):
                parent.children.append(image)
                image.parent = parent
