move gp tree code to new file