  Finding the exact close neighbors of each fluid element in mesh-free
computational hydrodynamical methods, such as the Smoothed Particle
Hydrodynamics (SPH), often becomes a main bottleneck for scaling their
performance beyond a few million fluid elements per computing node. Tree
structures are particularly suitable for SPH simulation codes, which rely on
finding the exact close neighbors of each fluid element (or SPH particle). In
this work we present a novel tree structure, named \textit{$b$-tree}, which
features an adaptive branching factor to reduce the depth of the neighbor
search. Depending on the particle spatial distribution, finding neighbors using
\tree has an asymptotic best case complexity of $O(n)$, as opposed to $O(n \log
n)$ for other classical tree structures such as octrees and quadtrees. We also
present the proposed tree structure as well as the algorithms to build it and
to find the exact close neighbors of all particles. We assess the scalability
of the proposed tree-based algorithms through an extensive set of performance
experiments in a shared-memory system. Results show that b-tree is up to
$12\times$ faster for building the tree and up to $1.6\times$ faster for
finding the exact neighbors of all particles when compared to its octree form.
Moreover, we apply b-tree to a SPH code and show its usefulness over the
existing octree implementation, where b-tree is up to $5\times$ faster for
finding the exact close neighbors compared to the legacy code.
