working max tree