You need to move the when outside the tuple and then it works
level = 4
has_children_or_no_children = :no_children
case {level, has_children_or_no_children} do
{n, :has_children} when n < 5 ->
1
{n, :no_children} when n > 0 ->
2
_ ->
false
end


















