Valid tree construction and simple error handling.