typedef struct PrototypeToken {

	int id ;
	int parentoffset ;
	int siblingrank ;
	int nchildren ;
	float PrototypeResult ;

} PrototypeToken ;



int PrototypeFunction ( )
{
	int i ;
	int * UPSTREAM ;
	int stacksize ;
	Stack = (PrototypeToken *) malloc ( sizeof(PrototypeToken) );
	
	stacksize = 1;
	Stack[0].id = outlet ;
	Stack[0].hasResult = 0 ;

	currentoffset = 0 ;
	push = 1 ;

	while ( stacksize>0 )
	{
		while ( push ) 
		{		
			free(UPSTREAM);
			GetUpstream ( F , & (Stack[currentoffset].id) , & nup , & UPSTREAM )
		
			if ( nup>0) 
			{
				Stack[currentoffset].nchildren = nup;

				// Push children on stack

				Stack = (PrototypeToken *) realloc ( Stack , (stacksize+nup)*sizeof(PrototypeToken) );
				for(i=0;i<nup;i++)
				{
					Stack[stacksize+i].id = UPSTREAM[i];
					Stack[stacksize+i].parentoffset = currentoffset ;
					Stack[stacksize+i].siblingrank = i ;						
				}	
				stacksize+=nup;
				currentoffset = stacksize-1;
				push = 1 ;
			}
			else
			{
				push = 0 ;
			}
		}

		// ******  Compute result here (token is leaf) ***********




		if ( Stack[currentoffset].siblingrank )
		{
			currentoffset-- ;
			push = 1 ;
		}

		// ******  Begin pop sequence **********

		while ( !push & stacksize>1 )
		{
			parentoffset = Stack[currentoffset].parentoffset ;
			nchildren = Stack[parentoffset].nchildren ;
				
			// Compute the result for the parent, children are at offsets currentoffset:(currentoffset+nchildren)
		
			for ()
			{

			}

			// Remove all tokens with offset >= currentoffset from the stack ;
					
			Stack = (PrototypeToken *) realloc ( Stack , currentoffset * sizeof(PrototypeToken) );
			stacksize = currentoffset ;
			currentoffset = parentoffset ;			

			if ( Stack[currentoffset].siblingrank )
			{
				currentoffset-- ;
				push = 1 ;
			}
		}	
	
	}
	
	return(0);
}
