Unification Algorithm without Occur Check I have been reading about Unification algorithm here https://en.wikipedia.org/wiki/Unification_(computer_science)#A_unification_algorithm 
. And I wonder about the importance of occur check. 

I know that without occur check an unsound inference may occur. But OTOH, does the algorithm always terminate without occur check? If the two literals to unify have no variables in common I feel like the algorithm should at least always terminate right?
Say you tried to solve $f(A, g(A)) = f(B, B)$ after applying $A \to B$ you'd then have $f(A, g(A)) = f(A, A)$ and you'd have to unify $A = g(A)$ as a sub problem.