Suppose there is an infinite single-rooted complete binary tree--i.e., every node except the root has a single parent, and every node has two children. There are also $n$ colors to choose from. The task is to paint as many full levels (sets of nodes equidistant to the root) as possible, starting with the root and without skipping any levels, with the following condition: No pair of nodes of the same color at the same level in the tree is painted the same color as any of their ancestors in common.
For example, the following trees are invalid $2$-colorings for the first three levels:
0 < 1 <
/ \ / \
0 1 0 1
/ \ / \ / \ / \
0 1 0 1 1 1 0 1
^ ^ ^ ^
For the former, the two 0's at the bottom level are painted the same color as the root, and in the latter, the two 1's on the left fail similarly.
The following is the only valid 2-coloring for 3 levels (up to relabeling and isomorphism):
0
/ \
0 1
/ \ / \
1 1 0 1
Let $L(n)$ be the maximum number of levels one can fully paint with $n$ colors. The question is whether there is a closed formula for $L(n)$, or how far can we characterize $L(n)$ otherwise.
Obs 1: There is an easy lower bound of $L(n) \geq n$ since we can paint each full level a different color.
Obs 2: There is a pigeonhole argument that says that for $2^k-1$ colors, one can't paint more than $k \cdot 2^k$ levels.
Obs 3: I ran some code to find the first values of $L(n)$, and I saw that $L(3) = 5$ since there was no 3-coloring of 6 levels, and we can paint the first 5 levels like this:
0
0 1
1 1 0 1
1 2 1 2 0 1 2 2
2 2 1 2 2 2 1 2 2 2 2 2 0 2 1 2
Clearly, $L(1) = 1$ and it can be shown that $L(2) = 3$. Does the pattern continue, and $L(n) = 2n-1$?