Pair toPair( HashMap<Arc,Pair> parents, HashMap<Arc,Pair> orphans ) 
		throws MVDException
	{
		if ( versions.nextSetBit(0)==0)
			throw new MVDException("Ooops! hint detected!");
		Pair p = new Pair( versions, data );
		if ( this.parent != null )
		{
			// we're a child - find our parent
			Pair q = parents.get( parent );
			if ( q != null )
			{
				q.addChild( p );
				// if this is the last child of the parent remove it
				if ( parent.numChildren() == q.numChildren() )
					parents.remove( parent );
			}
			else	// we're orphaned for now
				orphans.put( this, p );
		}
		else if ( children != null )
		{
			// we're a parent
			for ( int i=0;i<children.size();i++ )
			{
				Arc child = children.get( i );
				Pair r = orphans.get( child );
				if ( r != null )
				{
					p.addChild( r );
					orphans.remove( child );
				}
			}
			if ( p.numChildren() < this.numChildren() )
				parents.put( this, p );
		}
		return p;
	}