tree graph todict