Is the following use of next() allowed? - Apache TinkerPop