Algorithm for finding all loops in power system network