Added proper variable scope identification in tree