Abstract out tree iterator