some refactoring in for readCodeColorBufferToTree