Algorithm exploring the tree of semigroups