def METHOD_NAME(
    self,
    user: AbstractUser,
    element_type: ElementType,
    page: Page,
    before: Optional[Element] = None,
    **kwargs,
) -> Element:
    """
    Creates a new element for a page given the user permissions.
    :param user: The user trying to create the element.
    :param element_type: The type of the element.
    :param page: The page the element exists in.
    :param before: If set, the new element is inserted before this element.
    :param kwargs: Additional attributes of the element.
    :return: The created element.
    """
    CoreHandler().check_permissions(
        user,
        CreateElementOperationType.type,
        workspace=page.builder.workspace,
        context=page,
    )
    # Check we are on the same page.
    if before and page.id != before.page_id:
        raise ElementNotInSamePage()
    try:
        new_element = self.handler.METHOD_NAME(
            element_type, page, before=before, **kwargs
        )
    except CannotCalculateIntermediateOrder:
        self.recalculate_full_orders(user, page)
        # If the `find_intermediate_order` fails with a
        # `CannotCalculateIntermediateOrder`, it means that it's not possible
        # calculate an intermediate fraction. Therefore, must reset all the
        # orders of the elements (while respecting their original order),
        # so that we can then can find the fraction any many more after.
        before.refresh_from_db()
        new_element = self.handler.METHOD_NAME(
            element_type, page, before=before, **kwargs
        )
    element_created.send(
        self,
        element=new_element,
        user=user,
        before_id=before.id if before else None,
    )
    return new_element