lovely! And, no, it won't harm the tree. If it emerges, it will be a winged adult and fly off. Only caterpillars feed ... so it's already done any harm it was ever going to do. Now, what species ... ? I have an idea, but I'll just check a couple of books. Better still, could you collect it (preferably on a piece of branch, without disturbing it) and keep it contained to see what emerges??
the pupal shape looks very much like an Orchard Butterfly (Papilio aegeus), although it's more dusty-brown that usual. Beautiful insects! OK, their caterpillars do rather like citrus, but heh ... sharing is OK. They don't eat that much :)
Let's hope it's alive, and the dusty pupal case isn't a sign of something amiss inside (eg a parasite).