fixed infinite loop in find_value_for_item; wasn't handling cycles
correctly