order terms by parent Closes #2534.