public void buildTree(Instances data, SimpleLinearRegression[][] higherRegressions, 
			  double totalInstanceWeight, double higherNumParameters) throws Exception{

	//save some stuff
	m_totalInstanceWeight = totalInstanceWeight;
	m_train = new Instances(data);
	
	m_isLeaf = true;
	m_sons = null;
	
	m_numInstances = m_train.numInstances();
	m_numClasses = m_train.numClasses();				
	
	//init 
	m_numericData = getNumericData(m_train);		  
	m_numericDataHeader = new Instances(m_numericData, 0);
	
	m_regressions = initRegressions();
	m_numRegressions = 0;
	
	if (higherRegressions != null) m_higherRegressions = higherRegressions;
	else m_higherRegressions = new SimpleLinearRegression[m_numClasses][0];	

	m_numHigherRegressions = m_higherRegressions[0].length;	
        
        m_numParameters = higherNumParameters;
        
        //build logistic model
        if (m_numInstances >= m_numFoldsBoosting) {
            if (m_fixedNumIterations > 0){
                performBoosting(m_fixedNumIterations);
            } else if (getUseAIC()) {
                performBoostingInfCriterion();
            } else {
                performBoostingCV();
            }
        }
        
        m_numParameters += m_numRegressions;
	
	//only keep the simple regression functions that correspond to the selected number of LogitBoost iterations
	m_regressions = selectRegressions(m_regressions);

	boolean grow;
	//split node if more than minNumInstances...
	if (m_numInstances > m_minNumInstances) {
	    //split node: either splitting on class value (a la C4.5) or splitting on residuals
	    if (m_modelSelection instanceof ResidualModelSelection) {	
		//need ps/Ys/Zs/weights
		double[][] probs = getProbs(getFs(m_numericData));
		double[][] trainYs = getYs(m_train);
		double[][] dataZs = getZs(probs, trainYs);
		double[][] dataWs = getWs(probs, trainYs);
		m_localModel = ((ResidualModelSelection)m_modelSelection).selectModel(m_train, dataZs, dataWs);	
	    } else {
		m_localModel = m_modelSelection.selectModel(m_train);	
	    }
	    //... and valid split found
	    grow = (m_localModel.numSubsets() > 1);
	} else {
	    grow = false;
	}
	
	if (grow) {	
	    //create and build children of node
	    m_isLeaf = false;	    	    
	    Instances[] localInstances = m_localModel.split(m_train);	    
	    m_sons = new LMTNode[m_localModel.numSubsets()];
	    for (int i = 0; i < m_sons.length; i++) {
		m_sons[i] = new LMTNode(m_modelSelection, m_fixedNumIterations, 
					 m_fastRegression,  
					 m_errorOnProbabilities,m_minNumInstances,
                                        getWeightTrimBeta(), getUseAIC());
		//the "higherRegressions" (partial logistic model fit at higher levels in the tree) passed
		//on to the children are the "higherRegressions" at this node plus the regressions added
		//at this node (m_regressions).
		m_sons[i].buildTree(localInstances[i],
				  mergeArrays(m_regressions, m_higherRegressions), m_totalInstanceWeight, m_numParameters);		
		localInstances[i] = null;
	    }	    
	} 
    }