move nboundDependencies to TreeAnalysis
rename some values and functions
minor refactorings
extract duplicated code into closure