Prevent duplicate tree nodes, fix sorting error

@iwehrman