Remove spaces from input tree string