edit to get first leaf element