Changes for tree parsing

General function for tree parsing.