A cat has had a fortunate escape after it climbed more than 20m up a tree and couldn't get down!