add tree and stack