def find_existing_page(self, titles_hierarchy):
        """
        Find and return existing page matching the given titles hierarchy
        """
        # Step backwards through import doc's titles hierarchy with a parent
        # count which is the offset from the current level to each ancestor
        titles_filters = {'publishing_is_draft': True}
        for parent_count, ancestor_title \
                in enumerate(titles_hierarchy[::-1]):
            # Convert import doc's ancestor title and parent count into
            # a filter query of the form:
            #    translations__title=<entry (ancestor 0) title>
            #    parent__translations__title=<ancestor 1 title>
            #    parent__parent__translations__title=<ancestor 2 title>
            #    parent__parent__parent__translations__title=<ancestor 3 title>
            parent_path = '__'.join(['parent'] * parent_count)
            filter_name = '%s%stranslations__title' % (
                parent_path, parent_path and '__' or '')
            titles_filters[filter_name] = ancestor_title
        # Return a corresponding page if one exists
        return self.page_model.objects \
            .filter(**titles_filters) \
            .first()
Find and return existing page matching the given titles hierarchy