In this paper, an algorithm for set unification – which is a restricted case of the associative-commutative-idempotent (ACI) unification – is presented. The algorithm is able to unify finite sets containing arbitrary terms. It is nondeterministic and can easily be implemented in Prolog. Because of the simplicity of the algorithm, the computation of a single solution is quite fast, and the exact complexity of the algorithm and of the set unification problem itself can be analyzed easily. The algorithm is compared with some other set unification algorithms. All algorithms have single exponential complexity, because the set unification problem is NP-complete, but our exact complexity analysis provides more details. It is shown how the algorithm presented here can be used to solve a generalized set unification problem where sets with tails are admissible. The algorithm can be used in any logic programming language embedding (finite) sets, or in other contexts where set unification is needed, for example, in some unification-based grammar formalisms.