question: private static void addPreviousLayer ( List < List < Neuron > > layers , List < Neuron > sourceLayer , List < Neuron > layerToCheck ) { final int MAXLAYERS = 100 ; Set < Neuron > newLayerTemp = new HashSet < Neuron > ( ) ; boolean theNextLayerIsTheSourceLayer = false ; for ( Neuron neuron : layerToCheck ) { for ( Synapse synapse : neuron . getFanIn ( ) ) { Neuron sourceNeuron = synapse . getSource ( ) ; if ( sourceLayer . contains ( sourceNeuron ) ) { theNextLayerIsTheSourceLayer = true ; } if ( sourceNeuron == neuron ) { continue ; } newLayerTemp . add ( synapse . getSource ( ) ) ; } } if ( ( theNextLayerIsTheSourceLayer ) || ( newLayerTemp . size ( ) == 0 ) || ( layers . size ( ) > MAXLAYERS ) ) { layers . add ( sourceLayer ) ; } else { List < Neuron > newLayer = new ArrayList < Neuron > ( newLayerTemp ) ; Collections . sort ( newLayer , OrientationComparator . X_ORDER ) ; layers . add ( newLayer ) ; addPreviousLayer ( layers , sourceLayer , newLayer ) ; } }
target:  Helper method for getIntermedateLayers. Add the "next layer down" in the hierarchy.