def METHOD_NAME(self, tree_node, left, commit):
    """
    Recursively calculate the left and right value for a given node and its
    children.
    :param tree_node: A node of a MPTT tree
    :type tree_node: ~integreat_cms.cms.models.pages.page.Page
    :param left: The new left value of the node
    :type left: int
    :param commit: Whether changes should be written to the database
    :type commit: bool
    :return: The new right value of the node
    :rtype: int
    """
    right = left
    for child in tree_node.children.all():
        right = self.METHOD_NAME(child, right + 1, commit)
    right += 1
    valid = self.check_tree_fields(tree_node, left, right)
    if not valid and commit:
        if tree_node.parent:
            tree_node.tree_id = tree_node.parent.tree_id
            tree_node.depth = tree_node.parent.depth + 1
        tree_node.rgt = right
        tree_node.lft = left
        tree_node.save()
        logger.info("Fixed tree fields of %r", tree_node)
    self.pages_seen.append(tree_node.id)
    return right