I am trying to understand how the tree package in R works. The following code is from the an introduction o Statistical learning textbook.

library (tree)

library (ISLR2)

attach (Carseats)

set.seed(32603)

High <- factor(ifelse(Sales <= 8, "No", " Yes ") )

Carseats <- data.frame(Carseats , High)

##### fit a model on all variables except Sales

tree.carseats <- tree(High~.-Sales,Carseats)

summary(tree.carseats)

tree.carseats

plot (tree.carseats)

text (tree.carseats , pretty = 0)

My question is how does the algorithm decide when to stop? I see there are 5 observations in the bottom most nodes. Is there a threshold that when the number of observations is equal to that threshold the algorithm stops?