add id to pattern tree