added condition to addFlights() in case a node needs to be inserted as head