Created logic of Tree view