Some basic Tree - Data structure problems solved by Javascript