implement prefix tree