Median maintenance solution using a balanced search tree