The easiest way to align nodes on a level is to use
tier=<name of tier> for the relevant nodes.
I started by removing the manual adjustment for A and B and adding
Now, obviously, this has expanded the tree horizontally, which we don't want. There are various ways of avoiding this. One of the easiest is to use an empty node to help with the alignment.
If we then specify a tier for one of B's terminal nodes e.g.
tier=that, then we'd like this to end up above any of A's children. Adding an empty child to A and making its existing children into children of the new child achieves this fairly easily.
This strategy will adjust automatically in most cases if nodes are multi-line etc. (Manual adjustment might be needed in some cases.) This is because the adjustment in the A branch is a function of the content and shape of the B branch.
For this reason, I prefer this method to something like increasing
l sep because it is less work if I change something later and requires less trial-and-error.
The code below is also simplified a bit as version 2 of Forest offers several goodies which can do some of your customisation for you. In particular, I use the
edges library for the squared-off edges and the
children anchors for flexibility. However, if you've only got version 1 and cannot update, you can use the
tier= strategy just fine with your original code.