Added check for duplicate solutions based on solution depth in tree