Convert find_comp from recursive to iterative structure