The second match is required in the case of matching 'a.b.c' against {"a": {"b": 3} }. This case is covered in the test. Previously suggested map {}.orNull also broke tailrec.