Start with all leaves (nodes with degree ). Remove them. The remaining nodes form a smaller tree. Repeat: find the new leaves, remove them. Keep going until or nodes remain. Those are the centers.
This is like peeling an onion. The center is what is left at the core.
Implementation: use BFS-like layer removal, tracking degrees. When a node's degree drops to , add it to the next removal layer.