Here is the problem I am trying to solve:
Let $T \subseteq \mathbb{N}^{\leq \mathbb{N}}$ be a tree. Define a total ordering $<$ on $T$ such $<$ is a well ordering if and only if $T$ doesn't have an infinite branch.
My instinct is to order the nodes of $T$ lexicographically, but first ordered by length:
$t < s \iff |t| < |s|~\text{or}~$|t| = |s|$~\text{and}~t~\text{is lexicographically less than}~s$.
However, it seems like this will always be a well ordering, even if $T$ has infinite branches, so I am unsure why that is part of the question.
Let $S \neq \emptyset \subseteq T$. Define the sets of sequences $S_i = \{ s \in S : |s| = i \}$, and take the smallest $i$ so $S_i$ is nonempty. Because $\mathbb{N}$ is well ordered, $i^{\mathbb{N}}$ (sequences of length $i$) is also be well ordered by the lexicographic ordering because it's finite. So pick the smallest element of $S_i$, and that element is smaller than all the other $s \in S$.
Yes, the definition you've given does not work for exactly the reason you describe.
The first observation is that in order for paths in $T$ to correspond to descending sequences in the corresponding linear order $L$, we want to reverse how we approach length: if $s$ is a prefix of $t$, we want $t$ to be below $s$. As long as this condition is satisfied, every tree with a path yields an ill-founded linear order.
This suggests that we basically invert your definition, and simply place the $n$th "level" below the $(n-1)$th "level" uniformly - that is, satisfying the property $$\vert s\vert\succ\vert t\vert\implies s\triangleleft t$$ where $\triangleleft$ is the linear order we're building.
But this fails in the other direction: let $T$ be the tree of all sequences whose length is not greater than their first bit. So e.g. $s=(4,1,7)$ has length $3$ which is less than the first bit $s(1)=4$, and so is on $T$; but $t=(1,4,7)$ is not on $T$, since $\vert t\vert=3>1=t(1)$.
Clearly $T$ has no infinite path. But since $T$ has nodes of arbitrarily great height, the idea above will still yield an ill-founded order.
So we've come up with the following guesses:
If $s\prec t$ then we want $t\triangleleft s$.
However, we don't want the relationship between incomparable strings to be determined only by their respective lengths.
This second point brings us back to the idea of the lexicographic order, since that's the natural way to compare two incomparable nodes in the first place. I don't want to fully give away the answer, but we're close, so let me make one final observation. There are two natural ways to order the immediate successors of some string $s$: namely, compare their last bits, and either agree or disagree with the result. One of these is guaranteed to yield ill-foundedness even when we don't want it.
Putting this all together, we wind up with an idea for a definition which looks something like the following:
(Then we're left with the task of verifying that it works. This is far from obvious, unfortunately.)