handle input trees correctly

close #1