:- [diagnosis].
%Function to add variable for uniqueness checking.
isHittingSetTree(Tree) :-
	isHittingSetTree2(Tree, []). 

%When the end of branch has been reached.
isHittingSetTree2(leaf, _). 
%When a node turns empty. 
isHittingSetTree2(node([], []), _). 
%When a node isn't empty.
isHittingSetTree2(node([CurLabel|Labels], [CurChild|Children]), VisitedLabels) :-
	%Check if label has already been used up in the tree.
	not(member(CurLabel,VisitedLabels)),
	%Append label to list of checked labels
	append(VisitedLabels, [CurLabel], UpdatedVisitedLabels), 
	%Recursively search into depth of branch.
	isHittingSetTree2(CurChild, Appended), 
	%Recursively search into width of node.
	isHittingSetTree2(node(Labels, UpdatedVisitedLabels), VisitedLabels).
%If there are more or less labels then children, the tree will not match and 
%the function will rightfully report false.
