It occurs in a wide range of open to semi-open habitats, including gardens and parks, but it is rare or absent in deserts, dense forests (e.g. large parts of the Amazon rainforest) and at altitudes above 2000 meters .