Fixed Dangling Else, Added Check for Array, Modified Tree Output