private boolean reachable(ILexNameToken sought, LexNameSet nextset,
		Map<ILexNameToken, LexNameSet> dependencies, Stack<ILexNameToken> stack)
	{
		if (nextset == null)
		{
			return false;
		}
		
		if (nextset.contains(sought))
		{
			stack.push(sought);
			return true;
		}
		
		for (ILexNameToken nextname: nextset)
		{
			if (stack.contains(nextname))	// Been here before!
			{
				return false;
			}
			
			stack.push(nextname);
			
			if (reachable(sought, dependencies.get(nextname), dependencies, stack))
			{
				return true;
			}
			
			stack.pop();
		}
		
		return false;
    }
private boolean reachable ( ILexNameToken sought , LexNameSet nextset , Map < ILexNameToken , LexNameSet > dependencies , Stack < ILexNameToken > stack ) { if ( nextset == null ) { return false ; } if ( nextset . contains ( sought ) ) { stack . push ( sought ) ; return true ; } for ( ILexNameToken nextname : nextset ) { if ( stack . contains ( nextname ) ) { return false ; } stack . push ( nextname ) ; if ( reachable ( sought , dependencies . get ( nextname ) , dependencies , stack ) ) { return true ; } stack . pop ( ) ; } return false ; }
Return true if the name sought is reachable via the next set of names passed using
the dependency map. The stack passed records the path taken to find a cycle.