new tree analyzing algorithm