Every way to choose 2 of {1, 2, 3, 4}. Pick elements in increasing index order: after taking a[i], only a[i + 1] onward are candidates, so {1, 2} and {2, 1} cannot both appear. A leaf is reached when 2 are chosen: C(4, 2) = 6 leaves.
Generating all 6 combinations of 2 out of 4 values.
Take a[0] = 1: chosen is {1}. Candidates from now on start at index 1, so nothing to the left can be picked again.
Take 1 and recurse from index 1.
Take a[1] = 2: chosen is {1, 2}. Candidates from now on start at index 2, so nothing to the left can be picked again.
Take 2 and recurse from index 2.
2 chosen: a leaf. Combination 1: {1, 2}.
Leaf. Combination 1 is {1, 2}.
Back at index 1. Undo: drop 2, chosen is {1}. Try the next candidate.
Drop 2 and move on.
Take a[2] = 3: chosen is {1, 3}. Candidates from now on start at index 3, so nothing to the left can be picked again.
Take 3 and recurse from index 3.
2 chosen: a leaf. Combination 2: {1, 3}.
Leaf. Combination 2 is {1, 3}.
Back at index 2. Undo: drop 3, chosen is {1}. Try the next candidate.
Drop 3 and move on.
Take a[3] = 4: chosen is {1, 4}. Candidates from now on start at index 4, so nothing to the left can be picked again.
Take 4 and recurse from index 4.
2 chosen: a leaf. Combination 3: {1, 4}.
Leaf. Combination 3 is {1, 4}.
Back at index 0. Undo: drop 1, chosen is { }. Try the next candidate.
Drop 1 and move on.
Take a[1] = 2: chosen is {2}. Candidates from now on start at index 2, so nothing to the left can be picked again.
Take 2 and recurse from index 2.
Take a[2] = 3: chosen is {2, 3}. Candidates from now on start at index 3, so nothing to the left can be picked again.
Take 3 and recurse from index 3.
2 chosen: a leaf. Combination 4: {2, 3}.
Leaf. Combination 4 is {2, 3}.
Back at index 2. Undo: drop 3, chosen is {2}. Try the next candidate.
Drop 3 and move on.
Take a[3] = 4: chosen is {2, 4}. Candidates from now on start at index 4, so nothing to the left can be picked again.
Take 4 and recurse from index 4.
2 chosen: a leaf. Combination 5: {2, 4}.
Leaf. Combination 5 is {2, 4}.
Back at index 1. Undo: drop 2, chosen is { }. Try the next candidate.
Drop 2 and move on.
Take a[2] = 3: chosen is {3}. Candidates from now on start at index 3, so nothing to the left can be picked again.
Take 3 and recurse from index 3.
Take a[3] = 4: chosen is {3, 4}. Candidates from now on start at index 4, so nothing to the left can be picked again.
Take 4 and recurse from index 4.
2 chosen: a leaf. Combination 6: {3, 4}.
Leaf. Combination 6 is {3, 4}.
Back at index 2. Undo: drop 3, chosen is { }. Try the next candidate.
Drop 3 and move on.
Taking a[3] = 4 would leave 0 candidates for 1 more picks: not enough, so this branch and everything after it are pruned.
Pruned: not enough elements remain.
6 combinations: {1, 2} {1, 3} {1, 4} {2, 3} {2, 4} {3, 4}. Each appears once because indices only ever increase along a branch, and the pruning skipped every branch that could not reach 2.
6 combinations were generated.