An optimal greedy algorithm for wavelength allocation in directed tree networks