Optimize pathfinding operations (RIPD-537):
* Calculate and cache Account hashes without holding locks.
* Avoid repeated unnecessary calls to expensive functions.
* Fast hash-based path element comparison.
* Use emplace instead of find/insert