Novel tree-based algorithms for computational electromagnetics