fixing lastChild

fixing lastChild in case of whitespaces after the last tag