Example 2 Figure 3 is a Pythagorean tree grown by squares and isosceles right triangles according to a certain pattern. Observe the figure and answer the questions.
(1) At the far right end of each layer of the tree, there is a square marked with a number indicating the layer, starting from this square and counting counterclockwise, the number of squares in each layer: the first layer has 1; the second layer has 2; the third layer has 4; the fourth layer has 8; the fifth layer has $\qquad$; if this tree is a towering tree, then the $n$-th layer has $\qquad$ squares.
(2) If each isosceles right triangle in Figure 3 is considered a branch, please describe the quantitative relationship between the areas of the three squares on each branch: $\qquad$
(3) If the side length of each square in the $n$-th layer is $a$, then the side length of the square in the first layer is $\qquad$
(4) If the area of the square in the first layer is $S$, then the sum of the areas of all squares in the $n$-th layer is $\qquad$
Solution: (1) From the figure, we observe that the number of squares in each upper layer is twice the number of squares in the previous layer. Therefore, the fifth layer has 16 squares, and the $n$-th layer has $2^{n-1}$ squares.
(2) The sum of the areas of the two smaller squares on each branch equals the area of the larger square.
(3) It is easy to see that the area of a square in the $n$-th layer is $a^{2}$, so the total area of all squares in the $n$-th layer is $2^{n-1} a^{2}$. Since their total area equals the area of the large square in the first layer, the side length of the square in the first layer is
$$
\sqrt{2^{n-1} a^{2}}=\frac{\sqrt{2^{n}}}{2} a \text {. }
$$
(4) The total area of all squares in the $n$-th layer is $S$.

Investigation: If the triangle is an isosceles right triangle, the side length of the square in the $n$-th layer is $a_{n}$, and the side length of the square in the first layer is $a_{1}$, then $a_{1}=\frac{\sqrt{2^{n}}}{2} a_{n}$; the area of the square in the first layer is $S_{1}$, and the area of the square in the $n$-th layer is $S_{n}$, then $S_{1}=2^{n-1} S_{n}$; the total number of squares in $n$ layers is
$$
1+2^{1}+2^{2}+2^{3}+\cdots+2^{n-1}=2^{n}-1 .
$$