New algoritm for cycles detecting.