Two-level systems, generalized Riccati equation, quasi-periodic solutions, trees, resummation of divergent series, Cantor set