run Aim Weapon and Fire Weapon. Similarly, if Aim Weapon fails, you don't run Fire Weapon.
Next is this:
        selector
        {
            sequence
            {
                Visible enemy closer than 10m
                Aim Weapon
                Fire Weapon
            }
            Move
        }

This is a selector, it will fail if all its tasks fail. Succeed as soon as one succeeds.  That means that if the sequences we reviewed before succeeds you don't run Move. That means that Move only runs when Visible enemy closer than 10m (or any other task of the sequence) fails.
Next up:
    sequence
    {   
        HP > 50%
        selector
        {
            sequence
            {
                Visible enemy closer than 10m
                Aim Weapon
                Fire Weapon
            }
            Move
        }
    }

Hopefully, you can see how this works… If HP > 50% fails, you don't go into the selector.
Finally:
selector
{
    sequence
    {   
        HP > 50%
        selector
        {
            sequence
            {
                Visible enemy closer than 10m
                Aim Weapon
                Fire Weapon
            }
            Move
        }
    }
    Use Medkit
}

As you can see, if the prior sequence succeeds (which implies that HP > 50% succeeds), then you don't run Use Medkit. In fact, Use Medkit would only run in scenarios where HP > 50% failed.

For example, suppose I have the following tree and the AI encounters an enemy that's closer than 10m, so he starts to aim his weapon. But then while he's aiming, his HP drops below 50%. I would want the agent to stop the aiming/firing sequence and move to the "use medkit" action.

You would have to add a task that fails the sequence, for example:
selector
{
    sequence
    {   
        HP > 50%
        selector
        {
            sequence
            {
                Visible enemy closer than 10m
                HP > 50%
                Aim Weapon
                Fire Weapon
            }
            Move
        }
  