INCLUDES DEBUG STATEMENTS FOR CHECKING PARENTS; fixed problems with adding parents to sets