Convert tree interfaces to use std::unique_ptr

This should hopefully prevent leaks in the future, though all the
conversions between tree * and std::unique_ptr <tree> inside the
parser are bound to cause trouble.